本文整理匯總了TypeScript中rxjs/operators.combineLatest函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript combineLatest函數的具體用法?TypeScript combineLatest怎麽用?TypeScript combineLatest使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了combineLatest函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: constructor
constructor(private store: Store<any>) {
this.peoples$ = store
.select("peopleReducer")
.pipe(combineLatest(store.select("filterReducer")))
.pipe(map(this.filterFn));
this.peoples$.subscribe(people => console.log(people));
}
示例2: asDiagram
asDiagram('combineLatest')('should combine events from two cold observables', () => {
const e1 = cold('-a--b-----c-d-e-|');
const e2 = cold('--1--2-3-4---| ');
const expected = '--A-BC-D-EF-G-H-|';
const result = e1.pipe(combineLatest(e2, (a, b) => String(a) + String(b)));
expectObservable(result).toBe(expected, {
A: 'a1', B: 'b1', C: 'b2', D: 'b3', E: 'b4', F: 'c4', G: 'd4', H: 'e4'
});
});
示例3: it
it('should work with hot and hot', () => {
const e1 = hot('--a--^--b--c--|', { a: 'a', b: 'b', c: 'c' });
const e1subs = '^ !';
const e2 = hot('---e-^---f--g--|', { e: 'e', f: 'f', g: 'g' });
const e2subs = '^ !';
const expected = '----x-yz--|';
const result = e1.pipe(combineLatest(e2, (x, y) => x + y));
expectObservable(result).toBe(expected, { x: 'bf', y: 'cf', z: 'cg' });
expectSubscriptions(e1.subscriptions).toBe(e1subs);
expectSubscriptions(e2.subscriptions).toBe(e2subs);
});