本文整理汇总了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[]>
});