RxJava + Realm threading


#1

I use original Realm wrapper for RxJava. In this way:

Flowable<RealmResult<RealmUser> result =
realm.where(RealmUser.class)
.findAllAsync()
.asFlowable();

Data are loaded on Realm Background thread and emitted to Main thread. My problem is that I need to map large amount of Realm object to own POJO (independent business layer). Realm objects can not be passed between threads. It means that I must map objects on Main thread which is undesirable and blocks Main thread. Do you know to perform mapping on background thread and use similar way? Is possible emits unmanaged copy of RealmResult (on Background thread directly from Realm)? I can not find similar way.

Usage of copyFromRealm is not good choice, becasue result is same as in case of my custom mapping.

At this time I use new model class for users only with attributech which I need. Result is lower time of mapping, but on Main thread which cause UI artifacts.

Thanks