skip to content

delay

 

delay delays value emission by a given time

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const { rxObserver } = require('api/v0.3');
const { timer } = require('rxjs');
const { delay, take } = require('rxjs/operators');

// basic timer
const timer$ = timer(0, 10)
  .pipe(
    take(5)
  );

// same timer, values delayed by 15ms
const delayed$ = timer$.pipe(
    delay(15)
  );

timer$.subscribe(rxObserver('Basic timer'));
delayed$.subscribe(rxObserver('Delayed by 15ms'));

0msBasic timerstartcomplete00 11 22 33 44 Delayed by 15msstartcomplete00 11 22 33 44

To make more sophisticated per value delay — see delayWhen operator example