SubscribeOn and ObserveOn

The .subscribeOn() operator changes the scheduler where the Observer will start the execution, while the .observeOn() operator changes the scheduler where the actions will be executed after it is applied. The following .subscribeOn() action shows how it changed the scheduler for the entire Observable from the default one to the orange one; we can see this because the color of Observable lines and the color of dotted emission lines changed to orange:

The following diagram is a bit more complicated:

The first .observeOn() call changes the default scheduler from the default (blue in this case) to the orange scheduler. However, the next .subscribeOn() call is ignored because it happened after the .observeOn() call, and the Observer is already operating on a particular scheduler. We can see that the color of the Observable didn't change into blue, as the .subscribeOn() call asked.

Finally, the last .observeOn() call changed the scheduler again for the subsequent operations from the orange scheduler to the purple scheduler.

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

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