1 import { CombineLatestOperator } from '../observable/combineLatest';
2 import { Observable } from '../Observable';
3 import { OperatorFunction, ObservableInput } from '../types';
5 export function combineAll<T>(): OperatorFunction<ObservableInput<T>, T[]>;
6 export function combineAll<T>(): OperatorFunction<any, T[]>;
7 export function combineAll<T, R>(project: (...values: T[]) => R): OperatorFunction<ObservableInput<T>, R>;
8 export function combineAll<R>(project: (...values: Array<any>) => R): OperatorFunction<any, R>;
10 * Flattens an Observable-of-Observables by applying {@link combineLatest} when the Observable-of-Observables completes.
14 * `combineAll` takes an Observable of Observables, and collects all Observables from it. Once the outer Observable completes,
15 * it subscribes to all collected Observables and combines their values using the {@link combineLatest}</a> strategy, such that:
17 * * Every time an inner Observable emits, the output Observable emits
18 * * When the returned observable emits, it emits all of the latest values by:
19 * * If a `project` function is provided, it is called with each recent value from each inner Observable in whatever order they
20 * arrived, and the result of the `project` function is what is emitted by the output Observable.
21 * * If there is no `project` function, an array of all the most recent values is emitted by the output Observable.
27 * ### Map two click events to a finite interval Observable, then apply `combineAll`
30 * import { fromEvent, interval } from 'rxjs';
31 * import { map, combineAll, take } from 'rxjs/operators';
33 * const clicks = fromEvent(document, 'click');
34 * const higherOrder = clicks.pipe(
36 * interval(Math.random() * 2000).pipe(take(3))
40 * const result = higherOrder.pipe(
44 * result.subscribe(x => console.log(x));
47 * @see {@link combineLatest}
48 * @see {@link mergeAll}
50 * @param {function(...values: Array<any>)} An optional function to map the most recent values from each inner Observable into a new result.
51 * Takes each of the most recent values from each collected inner Observable as arguments, in order.
52 * @return {Observable<T>}
55 export function combineAll<T, R>(project?: (...values: Array<any>) => R): OperatorFunction<T, R> {
56 return (source: Observable<T>) => source.lift(new CombineLatestOperator(project));