I have task like this:
Observable.just(getMessagesFromDb()).
subscribeOn(Schedulers.newThread()).
observeOn(AndroidSchedulers.mainThread()).
subscribe(incomingMessages -> {
//do something
});
where getMessagesFromDb
is method synchronously getting messages, without multithreading inside. According to the RxAndroid documentation for subscribeOn method:
Asynchronously subscribes Observers to this Observable on the specified Scheduler
And there is my question - why is the database request executed on main thread? How to do it asynchronously?
No comments:
Post a Comment