1 import { OperatorFunction, ObservableInput } from '../types';
3 * Converts a higher-order Observable into a first-order Observable which
4 * concurrently delivers all values that are emitted on the inner Observables.
6 * <span class="informal">Flattens an Observable-of-Observables.</span>
10 * `mergeAll` subscribes to an Observable that emits Observables, also known as
11 * a higher-order Observable. Each time it observes one of these emitted inner
12 * Observables, it subscribes to that and delivers all the values from the
13 * inner Observable on the output Observable. The output Observable only
14 * completes once all inner Observables have completed. Any error delivered by
15 * a inner Observable will be immediately emitted on the output Observable.
18 * Spawn a new interval Observable for each click event, and blend their outputs as one Observable
20 * import { fromEvent, interval } from 'rxjs';
21 * import { map, mergeAll } from 'rxjs/operators';
23 * const clicks = fromEvent(document, 'click');
24 * const higherOrder = clicks.pipe(map((ev) => interval(1000)));
25 * const firstOrder = higherOrder.pipe(mergeAll());
26 * firstOrder.subscribe(x => console.log(x));
29 * Count from 0 to 9 every second for each click, but only allow 2 concurrent timers
31 * import { fromEvent, interval } from 'rxjs';
32 * import { take, map, mergeAll } from 'rxjs/operators';
34 * const clicks = fromEvent(document, 'click');
35 * const higherOrder = clicks.pipe(
36 * map((ev) => interval(1000).pipe(take(10))),
38 * const firstOrder = higherOrder.pipe(mergeAll(2));
39 * firstOrder.subscribe(x => console.log(x));
42 * @see {@link combineAll}
43 * @see {@link concatAll}
44 * @see {@link exhaust}
46 * @see {@link mergeMap}
47 * @see {@link mergeMapTo}
48 * @see {@link mergeScan}
49 * @see {@link switchAll}
50 * @see {@link switchMap}
53 * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of inner
54 * Observables being subscribed to concurrently.
55 * @return {Observable} An Observable that emits values coming from all the
56 * inner Observables emitted by the source Observable.
60 export declare function mergeAll<T>(concurrent?: number): OperatorFunction<ObservableInput<T>, T>;