Schedulers with Operators
Learn how Schedulers are used in conjunction with the .subscribeOn() and .observeOn() operators.
We'll cover the following...
We'll cover the following...
.subscribeOn()
The .subscribeOn() operator is used in the Observable chain to dictate where the Observable should operate–for example, the function inside of .create(). Rewriting the previous example using a Scheduler instead gives us:
Running the above code is similar to using a Thread in that the operations inside .create() now occurs in a separate thread provided by Schedulers.newThread(). The benefit of this approach over using a Thread is that tacking on a Scheduler to specify where the Observable should execute is declarative. We no longer have to worry about the ...