Using Realm with RxJava 2

Viewed 4714

I am using RxJava 2 in my Android application, and am integrating Realm. As far as I can tell, Realm only supports RxJava 1 by default, and allows an Observable to be returned when querying for RealmResults<?>, like so:

Realm.getDefaultInstance()
    .where(VideoBundle.class)
    .findAll()
    .asObservable()
    .first()

The Observable returned is from RxJava 1. How can I use Realm and RxJava 2 together? I have come across 2 relevant issues, found here and here, but no succinct answer was found. Additionally, the documentation (found here: https://realm.io/docs/java/latest/#rxjava) mentions creating a custom RxObservableFactory, but provides no resources on how to do so.

How can Realm be used with a project already using RxJava 2?

1 Answers
Related