本文整理汇总了TypeScript中rxjs/operators.delayWhen函数的典型用法代码示例。如果您正苦于以下问题:TypeScript delayWhen函数的具体用法?TypeScript delayWhen怎么用?TypeScript delayWhen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delayWhen函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: retryWhen
retryWhen(errors =>
errors.pipe(
// log error message
tap(val => console.log(`Value ${val} was too high!`)),
// restart in 5 seconds
delayWhen(val => timer(val * 1000))
)
示例2: delayWhen1
delayWhen1() {
// emit value every second
const message = interval(1000);
// emit value after five seconds
const delayForFiveSeconds = () => timer(5000);
// after 5 seconds, start emitting delayed interval values
const delayWhenExample = message.pipe(delayWhen(delayForFiveSeconds));
// log values, delayed for 5 seconds
// ex. output: 5s....1...2...3
const subscribe = delayWhenExample.subscribe(val => console.log(val));
}
示例3: return
return (errors: Observable<any>) =>
errors.pipe(
scan((count, error) => {
if (maxRetries >= 0 && count >= maxRetries) {
throw error;
}
return count + 1;
}, 0),
delayWhen(val =>
timer(
Math.min(val * delay, maxDelay || Number.MAX_SAFE_INTEGER),
undefined,
scheduler
)
)
);
示例4: retryWhen
retryWhen(error =>
error.pipe(
tap(error => console.error(error)),
tap(() => console.debug('Retrying in 3s...')),
delayWhen(() => timer(3000))
)
示例5: higherOrder
export function delayWhen<T>(this: Observable<T>, delayDurationSelector: (value: T) => Observable<any>,
subscriptionDelay?: Observable<any>): Observable<T> {
return higherOrder(delayDurationSelector, subscriptionDelay)(this);
}
示例6: of
observable1 = constructorZone1.run(() => {
return of(1, 2, 3).pipe(delayWhen((v: any) => {
return timer(v * 10);
}));
});
示例7: it
it('should support an empty notifier', () => {
const o = of(1, 2, 3).pipe(delayWhen(() => NEVER)); // $ExpectType Observable<number>
});