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

Using Transformations

In the existing flow, we can see some spots where we can extract several code blocks in unison. Consider the following example:

        .observeOn(AndroidSchedulers.mainThread())        .doOnError(this::showToastErrorNotificationMethod)        .observeOn(Schedulers.io())

This can be extracted as one operation because it is responsible for the display of errors in the Android UI. These three lines are used to achieve one goal, so it will make sense to represent them as a single operation.

We will see how this can be done using the ObservableTransformer interface and .compose() method on the Observables. However, before that, we will explore an alternative approach that will help us understand why the use of Transformers makes sense in situations ...

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