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

Simplifying code with Transformations

ObservableTransformer is a simple interface that defines a transformation on the Observable object as a whole instead of the individual items that the Observable produces. The ObservableTransformer interface is as follows:

package io.reactivex;public interface ObservableTransformer<Upstream, Downstream> {    ObservableSource<Downstream> apply(Observable<Upstream> upstream);}

Here, the .apply() method will apply a series of operations on the upstream (original) Observable when used in the .compose() method on the Observable.

Let's see an example with the error handling code that we examined before:

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

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