Rx.Observable.prototype.timeInterval([scheduler])
Records the time interval between consecutive values in an observable sequence.
Arguments
[scheduler=Rx.Observable.timeout]
(Scheduler
): Scheduler used to compute time intervals. If not specified, the timeout scheduler is used.
Returns
(Observable
): An observable sequence with time interval information on values.
Example
var source = Rx.Observable.timer(0, 1000)
.timeInterval()
.map(function (x) { return x.value + ':' + x.interval; })
.take(5);
var subscription = source.subscribe(
function (x) {
console.log('Next: ' + x);
},
function (err) {
console.log('Error: ' + err);
},
function () {
console.log('Completed');
});
// => Next: 0:0
// => Next: 1:1000
// => Next: 2:1000
// => Next: 3:1000
// => Next: 4:1000
// => Completed
Location
File:
Dist:
Prerequisites:
- If using
rx.time.js
NPM Packages:
NuGet Packages:
Unit Tests: