February 2020
Intermediate to advanced
412 pages
9h 36m
English
Two other helpful action operators are doOnSubscribe() and doOnDispose(). doOnSubscribe(Consumer<Disposable> onSubscribe) executes the function provided at the moment subscription occurs. It provides access to the Disposable object in case you want to call dispose() in that action. The doOnDispose(Action onDispose) operator performs the specified action when disposal is executed.
We use both operators to print when subscription and disposal occur, as shown in the following code snippet. Then, the emitted values go through, and then disposal is finally fired.
Let's now try and see how these operators are called:
import io.reactivex.rxjava3.core.Observable;public class Ch3_57 { public static void main(String[] ...
Read now
Unlock full access