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