本文整理汇总了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));
}
开发者ID:zwvista,项目名称:SampleMisc,代码行数:27,代码来源:combining.service.ts
示例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());
});
开发者ID:angular,项目名称:zone.js,代码行数:8,代码来源:rxjs.Observable.combine.spec.ts
示例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[]>
});
开发者ID:jaychsu,项目名称:RxJS,代码行数:3,代码来源:combineAll-spec.ts
示例4: higherOrder
export function combineAll<T, R>(this: Observable<ObservableInput<T>>, project?: (...values: Array<T>) => R): Observable<R> {
return higherOrder(project)(this);
}
开发者ID:DallanQ,项目名称:rxjs,代码行数:3,代码来源:combineAll.ts
注:本文中的rxjs/operators.combineAll函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论