How to combine Retrofit 2 with Realm and RxJava
问题 I want to save retrofit responses to realm on the background thread then pass it to the UI Thread, but its a bit tricky since Realm is very touchy with threads. so the code would look like something like this, please submit your edits to all better solutions :) restApi.userRealmList() .doOnNext(userRealmModels -> { if (userRealmModels != null){ mRealm = Realm.getInstance(mContext); mRealm.asObservable() .map(realm -> mRealm.copyToRealmOrUpdate(userEntity)) .subscribe(new Subscriber<Object>()