本文整理汇总了TypeScript中rxjs/operators.windowCount函数的典型用法代码示例。如果您正苦于以下问题:TypeScript windowCount函数的具体用法?TypeScript windowCount怎么用?TypeScript windowCount使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了windowCount函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: windowCount1
windowCount1() {
// emit every 1s
const source = interval(1000);
const example = source.pipe(
// start new window every 4 emitted values
windowCount(4),
tap(_ => console.log('NEW WINDOW!'))
);
const subscribeTwo = example
.pipe(
// window emits nested observable
mergeAll()
/*
output:
"NEW WINDOW!"
0
1
2
3
"NEW WINDOW!"
4
5
6
7
*/
)
.subscribe(val => console.log(val));
}
示例2: it
it('should return Never if source if Never', () => {
const source = cold('-');
const subs = '^';
const expected = 'w';
const w = cold('-');
const expectedValues = { w: w };
const result = source.pipe(windowCount(2, 1));
expectObservable(result).toBe(expected, expectedValues);
expectSubscriptions(source.subscriptions).toBe(subs);
});
示例3: asDiagram
asDiagram('windowCount(3)')('should emit windows with count 3, no skip specified', () => {
const source = hot('---a---b---c---d---e---f---g---h---i---|');
const sourceSubs = '^ !';
const expected = 'x----------y-----------z-----------w---|';
const x = cold( '---a---b---(c|) ');
const y = cold( '----d---e---(f|) ');
const z = cold( '----g---h---(i|) ');
const w = cold( '----|');
const expectedValues = { x: x, y: y, z: z, w: w };
const result = source.pipe(windowCount(3));
expectObservable(result).toBe(expected, expectedValues);
expectSubscriptions(source.subscriptions).toBe(sourceSubs);
});