June 2017
Intermediate to advanced
400 pages
8h 44m
English
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); ...Read now
Unlock full access