2 import { mergeAll } from './mergeAll';
3 import { OperatorFunction, ObservableInput } from '../types';
5 export function concatAll<T>(): OperatorFunction<ObservableInput<T>, T>;
6 export function concatAll<R>(): OperatorFunction<any, R>;
9 * Converts a higher-order Observable into a first-order Observable by
10 * concatenating the inner Observables in order.
12 * <span class="informal">Flattens an Observable-of-Observables by putting one
13 * inner Observable after the other.</span>
17 * Joins every Observable emitted by the source (a higher-order Observable), in
18 * a serial fashion. It subscribes to each inner Observable only after the
19 * previous inner Observable has completed, and merges all of their values into
20 * the returned observable.
22 * __Warning:__ If the source Observable emits Observables quickly and
23 * endlessly, and the inner Observables it emits generally complete slower than
24 * the source emits, you can run into memory issues as the incoming Observables
25 * collect in an unbounded buffer.
27 * Note: `concatAll` is equivalent to `mergeAll` with concurrency parameter set
32 * For each click event, tick every second from 0 to 3, with no concurrency
34 * import { fromEvent, interval } from 'rxjs';
35 * import { map, take, concatAll } from 'rxjs/operators';
37 * const clicks = fromEvent(document, 'click');
38 * const higherOrder = clicks.pipe(
39 * map(ev => interval(1000).pipe(take(4))),
41 * const firstOrder = higherOrder.pipe(concatAll());
42 * firstOrder.subscribe(x => console.log(x));
44 * // Results in the following:
45 * // (results are not concurrent)
46 * // For every click on the "document" it will emit values 0 to 3 spaced
47 * // on a 1000ms interval
48 * // one click = 1000ms-> 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3
51 * @see {@link combineAll}
53 * @see {@link concatMap}
54 * @see {@link concatMapTo}
55 * @see {@link exhaust}
56 * @see {@link mergeAll}
57 * @see {@link switchAll}
58 * @see {@link switchMap}
61 * @return {Observable} An Observable emitting values from all the inner
62 * Observables concatenated.
66 export function concatAll<T>(): OperatorFunction<ObservableInput<T>, T> {
67 return mergeAll<T>(1);