Life cycles and cautions using RxJava with Android

As always, be deliberate and careful about how you manage the life cycle of your subscriptions. Make sure that you do not rely on weak references in your Android app and do not assume that reactive streams will dispose of themselves because they will not! So always call dispose() on a Disposable instance when a piece of your Android application is no longer being used.

For example, let's say you create a simple app that displays the number of seconds since it was launched. For this exercise, create a new project and set up your layout as shown in the following code snippet in order to have timer_field in the TextView class:

 <?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayout ...

Get Learning RxJava - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.