timer() operator

The timer() operator has the job of emitting values after a certain amount of time. It comes in two flavors: you either emit just one value after a number of milliseconds, or you keep on emitting values with a certain amount of delay between them. Let's look at the two different flavors available:

// time/timer.jslet stream$ = Rx.Observable.timer(1000);// delay with 500 millisecondslet streamWithDelay$ = Rx.Observable.timer(1000, 500) // emits 0 after 1000 milliseconds, then no morestream$.subscribe(data => console.log(data));streamWithDelay$.subscribe(data => console.log(data));

Get Architecting Angular Applications with Redux, RxJS, and NgRx now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.