delayWhen
연산자(operator) 정의: delayWhen(selector: Function, sequence: Observable): Observable
Delay emitted values determined by provided function.
Examples
Example 1: Delay based on observable
//emit value every second
const message = Rx.Observable.interval(1000);
//emit value after five seconds
const delayForFiveSeconds = () => Rx.Observable.timer(5000);
//after 5 seconds, start emitting delayed interval values
const delayWhenExample = message.delayWhen(delayForFiveSeconds);
//log values, delayed for 5 seconds
//ex. output: 5s....1...2...3
const subscribe = delayWhenExample.subscribe(val => console.log(val));
Additional Resources
- delayWhen - Official docs
- Transformation operator: delay and delayWhen - André Staltz
Source Code: https://github.com/ReactiveX/rxjs/blob/master/src/operator/delayWhen.ts