UNPKG

1.54 kBTypeScriptView Raw
1import { ObservableInputTuple, OperatorFunction } from '../types';
2/**
3 * Merge the values from all observables to a 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 source errors, the resulting observable will error.
12 *
13 * ## Example
14 *
15 * Joining all outputs from multiple user input event streams
16 *
17 * ```ts
18 * import { fromEvent, map, mergeWith } from 'rxjs';
19 *
20 * const clicks$ = fromEvent(document, 'click').pipe(map(() => 'click'));
21 * const mousemoves$ = fromEvent(document, 'mousemove').pipe(map(() => 'mousemove'));
22 * const dblclicks$ = fromEvent(document, 'dblclick').pipe(map(() => 'dblclick'));
23 *
24 * mousemoves$
25 * .pipe(mergeWith(clicks$, dblclicks$))
26 * .subscribe(x => console.log(x));
27 *
28 * // result (assuming user interactions)
29 * // 'mousemove'
30 * // 'mousemove'
31 * // 'mousemove'
32 * // 'click'
33 * // 'click'
34 * // 'dblclick'
35 * ```
36 *
37 * @see {@link merge}
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