本文整理匯總了TypeScript中rxjs/operators.zip函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript zip函數的具體用法?TypeScript zip怎麽用?TypeScript zip使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了zip函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: range
return errors => range(1, 10).pipe(
zip(errors, (i, err) => {
if (i == 10) {
throw err;
}
return i;
}),
flatMap(i => timer(i * 1000)),
)
示例2: it
it('should initially return the same value for streaming and non-streaming get', (done: Function) => {
translations = {"TEST": "This is a test"};
translate.use('en');
translate.stream('TEST').pipe(zip(translate.get('TEST'))).subscribe((value: [string, string]) => {
const [streamed, nonStreamed] = value;
expect(streamed).toEqual('This is a test');
expect(streamed).toEqual(nonStreamed);
done();
});
});
示例3: ngOnInit
ngOnInit() {
this.text = `Bacon ipsum dolor amet tongue short loin short ribs pork chop drumstick picanha
pancetta shank cow shoulder salami corned beef swine pig sausage. Rump flank
sirloin kielbasa jowl chuck sausage jerky short loin chicken. Flank sirloin frankfurter
corned beef turducken. Beef ribs salami ribeye, t-bone meatloaf flank jerky tongue turkey`;
this.typewriter$ = from(this.text.split(''))
.pipe(scan((acc, curr) => acc + curr))
// @ts-ignore
.pipe(zip(interval(50), x => x));
}
示例4: retryWhen
retryWhen(attempts => range(1, maxTries)
.pipe(
zip(attempts, (i) => i),
map(i => i * i),
mergeMap(i => timer(i * ms))
)
示例5: it
it('should support rest parameter observables with type parameters', () => {
const o = of(1); // $ExpectType Observable<number>
const z = [of(2)]; // $ExpectType Observable<number>[]
const a = o.pipe(zip<number, number[]>(...z)); // $ExpectType Observable<number[]>
});