Using ObservableTransformer

The examples of this section require Google Guava as a dependency. If you removed it, then you need to add it back.

In Chapter 3, Basic Operators, we covered the collect() operator and used it to turn Observable<T> into Single<ImmutableList<T>>. Effectively, we want to collect T emissions into a Google Guava ImmutableList<T>. Suppose we do this operation enough times until it starts to feel redundant. Here, we use this ImmutableList operation for two different Observable sequences, one created by Observable.just() and another created by Observable.range():

import com.google.common.collect.ImmutableList;import io.reactivex.rxjava3.core.Observable;public class Ch9_01a {    public static void main(String[] args) { Observable. ...

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.