Sign in Go Pro

RxJava

RxJava 2 - Disposing of Subscriptions with Disposable

This lesson is for PRO members.

Upgrade today to get access to all the PRO lessons.

Unlock this lesson

Previous

About

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.

Related Lessons:
- Logging with Timber

Comments

There are no comments on this lesson, start the conversation below ...

>
You need to go PRO to post comments.

Lessons in RxJava