In this lesson you'll learn how to dispose of a RxJava 2 observable stream using the
Disposable interface (source). You'll be shown how to obtain a disposable instance via the
subscribe() method overloads. The
subscribe methods will be provided with a lambda expression that will consume the event. Since a lambda expression is used, a
LambaObservber (source) will be returned which you can use to dispose of the observable stream.
You'll also be exposed to the
subscribeWith() operator which accepts an
Observer instance and you'll learn how to provide a
DisposableObserver to this method in order to properly dispose of the observable sequence.
If you want to learn more about the history of the
isDisposed() method, please see this issue on the RxJava issues page on GitHub.
This lesson is demonstrated in Kotlin.
- Logging with Timber