RxJava: subscribeOn vs observeOn
Tomek Polański
4963

Thank you for your article, unfortunately there is something I didn’t understand about the usage of subscribeOn when using just.

Assume Observable.just called from the UI thread:

private boolean method() {
return false;
}
// 1st usage
Observable.just(this.method()) // UI
.subscribeOn(Schedulers.newThread())
.subscribe(new Action1<Boolean>() {
@Override
public void call(Boolean aBoolean) {
// RxNewThreadScheduler
}
});
// 2nd usage
Observable.just(this.method()) // UI
.observeOn(Schedulers.newThread())
.subscribe(new Action1<Boolean>() {
@Override
public void call(Boolean aBoolean) {
// RxNewThreadScheduler
}
});

How can I make method() to run from a different thread than the UI thread, for example, a computation thread?

Why there is no difference in the above mentioned code between 1st usage and 2nd usage ?

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.