O'Reilly logo

Learning RxJava by Thomas Nield

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

ObservableTransformer

Bring back Google Guava as a dependency. In Chapter 3, Basic Operators, we covered the collect() operator and used it to turn  Observable<T> into a 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 subscriptions:

 import com.google.common.collect.ImmutableList; import io.reactivex.Observable; public class Launcher {     public static void main(String[] args) {         Observable.just("Alpha", "Beta", "Gamma", "Delta", "Epsilon")                 .collect(ImmutableList::builder, ImmutableList.Builder::add)                 .map(ImmutableList.Builder::build) .subscribe(System.out::println); ...

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