Skip to content

Commit

Permalink
docs(combineAll): Update docs for combineAll (ReactiveX#4035)
Browse files Browse the repository at this point in the history
  • Loading branch information
pertrai1 authored and cartant committed Aug 21, 2018
1 parent ef3ff0b commit 6e5f773
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/internal/operators/combineAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,50 @@ export function combineAll<T>(): OperatorFunction<ObservableInput<T>, T[]>;
export function combineAll<T>(): OperatorFunction<any, T[]>;
export function combineAll<T, R>(project: (...values: T[]) => R): OperatorFunction<ObservableInput<T>, R>;
export function combineAll<R>(project: (...values: Array<any>) => R): OperatorFunction<any, R>;
/**
* Flattens an Observable-of-Observables by applying {@link combineLatest} when the Observable-of-Observables completes.
*
* ![](combineAll.png)
*
* `combineAll` takes an Observable of Observables, and collects all Observables from it. Once the outer Observable completes,
* it subscribes to all collected Observables and combines their values using the {@link combineLatest}</a> strategy, such that:
*
* * Every time an inner Observable emits, the output Observable emits
* * When the returned observable emits, it emits all of the latest values by:
* * If a `project` function is provided, it is called with each recent value from each inner Observable in whatever order they
* arrived, and the result of the `project` function is what is emitted by the output Observable.
* * If there is no `project` function, an array of all the most recent values is emitted by the output Observable.
*
* ---
*
* ## Examples
* ### Map two click events to a finite interval Observable, then apply `combineAll`
* ```javascript
* import { map, combineAll, take } from 'rxjs/operators';
* import { fromEvent } from 'rxjs/observable/fromEvent';
*
* const clicks = fromEvent(document, 'click');
* const higherOrder = clicks.pipe(
* map(ev =>
* interval(Math.random() * 2000).pipe(take(3))
* ),
* take(2)
* );
* const result = higherOrder.pipe(
* combineAll()
* );
*
* result.subscribe(x => console.log(x));
* ```
*
* @see {@link combineLatest}
* @see {@link mergeAll}
*
* @param {function(...values: Array<any>)} An optional function to map the most recent values from each inner Observable into a new result.
* Takes each of the most recent values from each collected inner Observable as arguments, in order.
* @return {Observable<T>}
* @name combineAll
*/
export function combineAll<T, R>(project?: (...values: Array<any>) => R): OperatorFunction<T, R> {
return (source: Observable<T>) => source.lift(new CombineLatestOperator(project));
}

0 comments on commit 6e5f773

Please sign in to comment.