Composing multiple operators with the Observable.compose operator

The compose() operator has one parameter of type Transformer. The Transformer interface, like the Operator one, is an empty interface that extends Func1 (this approach hides the type complexities that are involved by using Func1). The difference is that it extends the Func1<Observable<T>, Observable<R>> method, so that it transforms an Observable and not a Subscriber. This means that, instead of operating on each individual item emitted by the source observable, it operates directly on the source.

We can illustrate the use of this operator and the Transformer interface through an example. First, we will create a Transformer implementation:

public class OddFilter<T> implements Transformer<T, ...

Get Learning Reactive Programming with Java 8 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.