本文整理匯總了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);
});