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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.157.34