delay

signature: delay(delay: number | Date, scheduler: Scheduler): Observable

Delay emitted values by given time.

Examples

Example 1: Delay for increasing durations

( jsBin | jsFiddle )

//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


:file_folder: Source Code: https://github.com/ReactiveX/rxjs/blob/master/src/operator/delay.ts

results matching ""

    No results matching ""