Hello.
My Observable is very simple and looks like:
Observable.create(new Observable.OnSubscribe<Content>() {
@Override
public void call(final Subscriber<? super Content> subscriber) {
final ContentObserver observer = new ContentObserver() {
@Override
public void onContentChanged() {
subscriber.onNext(loadContent());
}
};
subscriber.add(Subscriptions.create(new Action0() {
@Override
public void call() {
unregisterContentObserver(observer);
}
}));
registerContentObserver(observer);
subscriber.onNext(loadContent());
}
});
loadContent is a heavy operation and have to be executed on the background thread (which is provided by the Scheduler that I pass to subscribeOn method).
PROBLEM
onContentChanged is always invoked from the UI thread and this cannot be changed, so I need to reschedule loadContent call to the background thread, but I failed to find a way to get a current Scheduler.
What is the right way to do it?
Hello.
My
Observableis very simple and looks like:loadContentis a heavy operation and have to be executed on the background thread (which is provided by theSchedulerthat I pass tosubscribeOnmethod).PROBLEM
onContentChangedis always invoked from the UI thread and this cannot be changed, so I need to rescheduleloadContentcall to the background thread, but I failed to find a way to get a currentScheduler.What is the right way to do it?