O'Reilly logo

Reactive Android Programming by Tadas Subonis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Cleaning up Subscriptions

By now, it has become crystal clear that Subscriptions have to be cleaned up because they will cause memory and thread leaks otherwise.

In this section, we will explore a few different ways to correctly destroy Subscriptions. One of the simplest options would be to use the Disposable interface. In addition to that, we will see how the RxLifecycle library can be used to make lifecycle management almost automatic, and we will check out a few examples of how to do that.

Finally, not every Subscription needs to be canceled or destroyed manually. Consider that it is just a simple call, as follows:

Observable.just(1)        .subscribe();

Here, we can be sure that it will quickly complete, and it will terminate automatically. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required