UNPKG

1.56 kBTypeScriptView Raw
1import { ObservableInputTuple, OperatorFunction } from '../types';
2/**
3 * Merge the values from all observables to an single observable result.
4 *
5 * Creates an observable, that when subscribed to, subscribes to the source
6 * observable, and all other sources provided as arguments. All values from
7 * every source are emitted from the resulting subscription.
8 *
9 * When all sources complete, the resulting observable will complete.
10 *
11 * When any one source errors, the resulting observable will error.
12 *
13 *
14 * ### Example
15 *
16 * Joining all outputs from multiple user input event streams:
17 *
18 * ```ts
19 * import { fromEvent } from 'rxjs';
20 * import { map, mergeWith } from 'rxjs/operators';
21 *
22 * const clicks$ = fromEvent(document, 'click').pipe(map(() => 'click'));
23 * const mousemoves$ = fromEvent(document, 'mousemove').pipe(map(() => 'mousemove'));
24 * const dblclicks$ = fromEvent(document, 'dblclick').pipe(map(() => 'dblclick'));
25 *
26 * mousemoves$.pipe(
27 * mergeWith(clicks$, dblclicks$),
28 * )
29 * .subscribe(x => console.log(x));
30 *
31 * // result (assuming user interactions)
32 * // "mousemove"
33 * // "mousemove"
34 * // "mousemove"
35 * // "click"
36 * // "click"
37 * // "dblclick"
38 * ```
39 * @param otherSources the sources to combine the current source with.
40 * @return A function that returns an Observable that merges the values from
41 * all given Observables.
42 */
43export declare function mergeWith<T, A extends readonly unknown[]>(...otherSources: [...ObservableInputTuple<A>]): OperatorFunction<T, T | A[number]>;
44//# sourceMappingURL=mergeWith.d.ts.map
\No newline at end of file