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 like this.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.158.134