When working with RxJava, you may find yourself wanting to reuse pieces of an Observable
or Flowable
chain and somehow consolidate these operators into a new operator. Good developers find opportunities to reuse code, and RxJava provides this ability using ObservableTransformer
and FlowableTransformer
, which you can pass to the compose()
operator.
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...