March 2018
Intermediate to advanced
364 pages
8h 21m
English
Another interesting operator is the interval() operator, which takes a number of milliseconds as a parameter. This defines the number of milliseconds delay there should be between every piece of emitted data. This will start from the number 0. One thing to keep in mind is that it will generate values forever unless, for example, a take() operator is applied to it. A take() operator will limit the number of emitted values and close the stream. A typical usage of the operator is the following:
let stream$ = Rx.Observable.interval(1000) .take(3); // 1s delay between values, starting at 0stream$.subscribe(data => console.log(data)) // 0, 1, 2
Read now
Unlock full access