combineAll

signature: combineAll(project: function): Observable

When source observable completes use combineLatest with collected observables.

Examples

( example tests )

Example 1: Mapping to inner interval observable

( jsBin | jsFiddle )

//emit every 1s, take 2
const source = Rx.Observable.interval(1000).take(2);
//map first value to 500ms interval and second to 1s, take two values
const example = source.map(val => Rx.Observable.interval(val + 500).take(2));
/*
  2 values from source will map to 2 (inner) interval observables that emit every .5s
  and 1s. combineAll uses combineLatest strategy, emitting the last value from each
  whenever either observable emits a value
*/
const combined = example.combineAll();
/*
  output:
  [0,0]
  [1,0]
  [1,1]
*/
const subscribe = combined.subscribe(val => console.log(val));

Additional Resources


:file_folder: Source Code: https://github.com/ReactiveX/rxjs/blob/master/src/operator/combineAll.ts

results matching ""

    No results matching ""