This repository has been archived by the owner. It is now read-only.
Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
62 lines (48 sloc) 2.06 KB

This is RxJS v 4. Find the latest version here

Rx.Observable.prototype.timeInterval([scheduler])

Records the time interval between consecutive values in an observable sequence.

Arguments

  1. [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:

NPM Packages:

NuGet Packages:

Unit Tests: