本文整理汇总了TypeScript中rxjs/operators.combineAll函数的典型用法代码示例。如果您正苦于以下问题:TypeScript combineAll函数的具体用法?TypeScript combineAll怎么用?TypeScript combineAll使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了combineAll函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: combineAll1
combineAll1() {
// emit every 1s, take 2
const source = interval(1000).pipe(take(2));
// map each emitted value from source to interval observable that takes 5 values
const example = source.pipe(
map(val => interval(1000).pipe(map(i => `Result (${val}): ${i}`), take(5)))
);
/*
2 values from source will map to 2 (inner) interval observables that emit every 1s
combineAll uses combineLatest strategy, emitting the last value from each
whenever either observable emits a value
*/
const combined = example.pipe(combineAll());
/*
output:
["Result (0): 0", "Result (1): 0"]
["Result (0): 1", "Result (1): 0"]
["Result (0): 1", "Result (1): 1"]
["Result (0): 2", "Result (1): 1"]
["Result (0): 2", "Result (1): 2"]
["Result (0): 3", "Result (1): 2"]
["Result (0): 3", "Result (1): 3"]
["Result (0): 4", "Result (1): 3"]
["Result (0): 4", "Result (1): 4"]
*/
const subscribe = combined.subscribe(val => console.log(val));
}
示例2: of
observable1 = constructorZone1.run(() => {
const source = of(1, 2);
const highOrder = source.pipe(map((src: any) => {
expect(Zone.current.name).toEqual(constructorZone1.name);
return of(src);
}));
return highOrder.pipe(combineAll());
});
示例3: it
it('should infer correctly with the projector', () => {
const o = of([1, 2, 3]).pipe(combineAll((values: number) => ['x', 'y', 'z'])); // $ExpectType Observable<string[]>
});
示例4: higherOrder
export function combineAll<T, R>(this: Observable<ObservableInput<T>>, project?: (...values: Array<T>) => R): Observable<R> {
return higherOrder(project)(this);
}