Skip to content

Latest commit

 

History

History
67 lines (54 loc) · 3 KB

timer.md

File metadata and controls

67 lines (54 loc) · 3 KB

Rx.Observable.timer(dueTime, [period], [scheduler])

Returns an observable sequence that produces a value after dueTime has elapsed and then after each period. Note for rx.lite.js, only relative time is supported.

Arguments

  1. dueTime (Date|Number): Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) at which to produce the first value.
  2. [period|scheduler=Rx.Scheduler.timeout] (Number|Scheduler): Period to produce subsequent values (specified as an integer denoting milliseconds), or the scheduler to run the timer on. If not specified, the resulting timer is not recurring.
  3. [scheduler=Rx.Scheduler.timeout] (Scheduler): Scheduler to run the timer on. If not specified, the timeout scheduler is used.

Returns

(Observable): An observable sequence that produces a value after due time has elapsed and then each period.

Example

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

Location

File:

Dist:

Prerequisites:

NPM Packages:

NuGet Packages:

Unit Tests: