Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
32 lines (25 sloc) 676 Bytes

Delay value emission by a given time

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'));

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

You can’t perform that action at this time.