interval()

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 0

stream$.subscribe(data => console.log(data))
// 0, 1, 2
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.75.221