O'Reilly logo

Reactive Android Programming by Tadas Subonis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Rules of thumb

While using .observeOn() and .subscribeOn(), there are two rules of thumb:

  1. Place .subscribeOn() as early as possible in the flow of the Observable; this helps you to see which Scheduler the Subscription starts on
  2. Place .observeOn() just before .subscribe(); in cases where only a single .observeOn() is used, it helps you see on which Scheduler the .subscribe() action will be executed right away

Obviously, there will be lots of cases when they will be needed somewhere else in the chain or even having multiple calls to them will be necessary. However, it is recommended to start like this.

Finally, if there is no need for the .subscribeOn() and .observeOn() calls, they should be omitted.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required