Debian Codegraph @

node/rxjs/src/internal/operators/zipWith.ts

raw
1 import { ObservableInputTuple, OperatorFunction, Cons } from '../types';
2 import { zip } from './zip';
3
4 /**
5 * Subscribes to the source, and the observable inputs provided as arguments, and combines their values, by index, into arrays.
6 *
7 * What is meant by "combine by index": The first value from each will be made into a single array, then emitted,
8 * then the second value from each will be combined into a single array and emitted, then the third value
9 * from each will be combined into a single array and emitted, and so on.
10 *
11 * This will continue until it is no longer able to combine values of the same index into an array.
12 *
13 * After the last value from any one completed source is emitted in an array, the resulting observable will complete,
14 * as there is no way to continue "zipping" values together by index.
15 *
16 * Use-cases for this operator are limited. There are memory concerns if one of the streams is emitting
17 * values at a much faster rate than the others. Usage should likely be limited to streams that emit
18 * at a similar pace, or finite streams of known length.
19 *
20 * In many cases, authors want `combineLatestWith` and not `zipWith`.
21 *
22 * @param otherInputs other observable inputs to collate values from.
23 * @return A function that returns an Observable that emits items by index
24 * combined from the source Observable and provided Observables, in form of an
25 * array.
26 */
27 export function zipWith<T, A extends readonly unknown[]>(...otherInputs: [...ObservableInputTuple<A>]): OperatorFunction<T, Cons<T, A>> {
28 return zip(...otherInputs);
29 }