A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://reactivex.io/documentation/operators/timer.html below:

ReactiveX - Timer operator

In RxJS there are two versions of the timer operator.

The first version of timer returns an Observable that emits a single item after a delay period you specify. You can specify the delay either as a Date object (which means, delay until that absolute moment) or as an integer (which means, delay that many milliseconds).

There is also a version of timer that returns an Observable that emits a single item after a specified delay, and then emits items periodically thereafter on a specified periodicity. In this way it behaves a bit more like the Interval operator.

Sample Code
var source = Rx.Observable.timer(200, 100)
    .timeInterval()
    .pluck('interval')
    .take(3);

var subscription = source.subscribe(
    function (x) {
        console.log('Next: ' + x);
    },
    function (err) {
        console.log('Error: ' + err);
    },
    function () {
        console.log('Completed');
    });
Next: 200
Next: 100
Next: 100
Completed

timer by default operates on the timeout Scheduler, or you can override this by passing in a Scheduler as a final parameter.

timer is found in each of the following distributions:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4