UNPKG

2.33 kBTypeScriptView Raw
1import { OperatorFunction, ObservableInput, ObservedValueOf } from '../types';
2/**
3 * Converts a higher-order Observable into a first-order Observable which
4 * concurrently delivers all values that are emitted on the inner Observables.
5 *
6 * <span class="informal">Flattens an Observable-of-Observables.</span>
7 *
8 * ![](mergeAll.png)
9 *
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.
16 *
17 * ## Examples
18 *
19 * Spawn a new interval Observable for each click event, and blend their outputs as one Observable
20 *
21 * ```ts
22 * import { fromEvent, map, interval, mergeAll } from 'rxjs';
23 *
24 * const clicks = fromEvent(document, 'click');
25 * const higherOrder = clicks.pipe(map(() => interval(1000)));
26 * const firstOrder = higherOrder.pipe(mergeAll());
27 *
28 * firstOrder.subscribe(x => console.log(x));
29 * ```
30 *
31 * Count from 0 to 9 every second for each click, but only allow 2 concurrent timers
32 *
33 * ```ts
34 * import { fromEvent, map, interval, take, mergeAll } from 'rxjs';
35 *
36 * const clicks = fromEvent(document, 'click');
37 * const higherOrder = clicks.pipe(
38 * map(() => interval(1000).pipe(take(10)))
39 * );
40 * const firstOrder = higherOrder.pipe(mergeAll(2));
41 *
42 * firstOrder.subscribe(x => console.log(x));
43 * ```
44 *
45 * @see {@link combineLatestAll}
46 * @see {@link concatAll}
47 * @see {@link exhaustAll}
48 * @see {@link merge}
49 * @see {@link mergeMap}
50 * @see {@link mergeMapTo}
51 * @see {@link mergeScan}
52 * @see {@link switchAll}
53 * @see {@link switchMap}
54 * @see {@link zipAll}
55 *
56 * @param {number} [concurrent=Infinity] Maximum number of inner
57 * Observables being subscribed to concurrently.
58 * @return A function that returns an Observable that emits values coming from
59 * all the inner Observables emitted by the source Observable.
60 */
61export declare function mergeAll<O extends ObservableInput<any>>(concurrent?: number): OperatorFunction<O, ObservedValueOf<O>>;
62//# sourceMappingURL=mergeAll.d.ts.map
\No newline at end of file