本文基于Rxjava 2.x版本,介绍用于操作多个 Observable 对象的操作符。
Operators that work with multiple source Observables to create a single Observable
- And/Then/When — combine sets of items emitted by two or more Observables by means of
Pattern
andPlan
intermediaries - CombineLatest — when an item is emitted by either of two Observables, combine the latest item emitted by each Observable via a specified function and emit items based on the results of this function
- Join — combine items emitted by two Observables whenever an item from one Observable is emitted during a time window defined according to an item emitted by the other Observable
- Merge — combine multiple Observables into one by merging their emissions
- StartWith — emit a specified sequence of items before beginning to emit the items from the source Observable
- Switch — convert an Observable that emits Observables into a single Observable that emits the items emitted by the most-recently-emitted of those Observables
- Zip — combine the emissions of multiple Observables together via a specified function and emit single items for each combination based on the results of this function