Rx.Observable.interval(period, [scheduler])
Returns an observable sequence that produces a value after each period.
Arguments
period
(Number
): Period for producing the values in the resulting sequence (specified as an integer denoting milliseconds).[scheduler]
(Scheduler=Rx.Scheduler.timeout): Scheduler to run the timer on. If not specified, Rx.Scheduler.timeout is used.
Returns
(Observable
): An observable sequence that produces a value after each period. Each value produced will default to a Number
denoting its order in the timeline. (e.g. 0, 1, 2...
)
Example
var source = Rx.Observable
.interval(500 /* ms */)
.timeInterval()
.take(3);
var subscription = source.subscribe(
function (x) {
console.log('Next: ' + x);
},
function (err) {
console.log('Error: ' + err);
},
function () {
console.log('Completed');
});
// => Next: {value: 0, interval: 500}
// => Next: {value: 1, interval: 500}
// => Next: {value: 2, interval: 500}
// => Completed
Location
File:
Dist:
Prerequisites:
- if
rx.time.js
rx.lite.js
|rx.lite.compat.js
NPM Packages:
NuGet Packages:
Unit Tests: