delay
연산자(operator) 정의: delay(delay: number | Date, scheduler: Scheduler): Observable
Delay emitted values by given time.
Examples
Example 1: Delay for increasing durations
//emit one item
const example = Rx.Observable.of(null);
//delay output of each by an extra second
const message = Rx.Observable.merge(
example.mapTo('Hello'),
example.mapTo('World!').delay(1000),
example.mapTo('Goodbye').delay(2000),
example.mapTo('World!').delay(3000)
);
//output: 'Hello'...'World!'...'Goodbye'...'World!'
const subscribe = message.subscribe(val => console.log(val));
Additional Resources
- delay - Official docs
- Transformation operator: delay and delayWhen - André Staltz
Source Code: https://github.com/ReactiveX/rxjs/blob/master/src/operator/delay.ts