mergeAll
signature: mergeAll(concurrent: number): Observable
mergeAll(concurrent: number): ObservableCollect and subscribe to all observables.
Examples
// RxJS v6+
import { map, mergeAll } from 'rxjs/operators';
import { of } from 'rxjs';
const myPromise = val =>
new Promise(resolve => setTimeout(() => resolve(`Result: ${val}`), 2000));
//emit 1,2,3
const source = of(1, 2, 3);
const example = source.pipe(
//map each value to promise
map(val => myPromise(val)),
//emit result from source
mergeAll()
);
/*
output:
"Result: 1"
"Result: 2"
"Result: 3"
*/
const subscribe = example.subscribe(val => console.log(val));Additional Resources
Last updated