skip to content

timer

 

emit once

timer(msDelay) will emit once after a given delay

1
2
3
4
5
6
7
8
9
const { rxObserver } = require('api/v0.3');
const { timer } = require('rxjs');
const { take } = require('rxjs/operators');

// will emit once in 10ms
timer(10)
  .subscribe(rxObserver('timer(10)'));

0mstimer(10)startcomplete00

emit with interval

timer(msDelay, msInterval) after a given delay will start emitting sequential number values with a given interval

1
2
3
4
5
6
7
8
9
10
11
12
const { rxObserver } = require('api/v0.3');
const { timer } = require('rxjs');
const { take } = require('rxjs/operators');

// will start emiting in 10ms
// with 5ms interval
timer(10, 5).pipe(
    take(4)
  )
  .subscribe(rxObserver('timer(10, 5)'));

0mstimer(10, 5)startcomplete00 11 22 33