June 2017
Intermediate to advanced
400 pages
8h 44m
English
Two other helpful action operators are doOnSubscribe() and doOnDispose(). The doOnSubscribe() fires a specific Consumer<Disposable> the moment subscription occurs at that point in the Observable chain. It provides access to the Disposable in case you want to call dispose() in that action. The doOnDispose() operator will perform a specific action when disposal is executed at that point in the Observable chain.
We use both operators to print when subscription and disposal occur, as shown in the following code snippet. As you can predict, we see the subscribe event fire off first. Then, the emissions go through, and then disposal is finally fired:
import io.reactivex.Observable;public class Launcher { public ...
Read now
Unlock full access