Scheduler Behavior
Learn how Schedulers work in detail.
We'll cover the following...
As we can see, using .subscribeOn()
and .observeOn()
makes threading easy, but there are some intricacies to these operators that need to be discussed.
.subscribeOn()
As pointed out earlier, it doesn’t matter where the .subscribeOn()
call appears in the operator chain. However, it’s important to note that only the first .subscribeOn()
call is applied. Any subsequent .subscribeOn()
calls will have no effect. Oftentimes, Observable
objects are created as part of a library or API and provided to a client via an interface. This interface documentation should clearly state if the returned Observable
will have already been relegated to some Scheduler
via .subscribeOn()
because, if it has, the client will no longer be able to make its own .subscribeOn()
call. ...