The subscribeOn()
operator instructs the source Observable
which Scheduler
to emit emissions on. If subscribeOn()
is the only concurrent operation in an Observable
chain, the thread from that Scheduler
will work the entire Observable
chain, pushing emissions from the source all the way to the final Observer
. The observeOn()
operator, however, will intercept emissions at that point in the Observable
chain and switch them to a different Scheduler
going forward.
Unlike subscribeOn()
, the placement of observeOn()
matters. It will leave all operations upstream on the default or subscribeOn()
-defined Scheduler
, but will switch to a different Scheduler
downstream. Here, I can have an Observable
emit a series of strings that are /
-separated values and break them up on an IO Scheduler
. But after that, I can switch to a computation Scheduler
to filter only numbers and calculate their sum, as shown in the following code snippet:
import io.reactivex.Observable; import io.reactivex...