February 2020
Intermediate to advanced
412 pages
9h 36m
English
Earlier, we skipped talking about the onSubscribe() method in Observer, but now we will address it. You may have noticed that Disposable is passed in the implementation of an Observer through the onSubscribe() method. This method was added in RxJava 2.0, and it allows the Observer to have the ability to dispose of the subscription at any time.
For instance, you can implement your own Observer and use onNext(), onComplete(), or onError() to have access to the Disposable. This way, these three events can call dispose() if, for whatever reason, the Observer does not want any more emissions:
Observer<Integer> myObserver = new Observer<Integer>() { private Disposable disposable; @Override public void ...
Read now
Unlock full access