The timestamp
method attaches a timestamp to each item emitted by the source Observable
before emitting that item as part of its own sequence. The timestamp indicates when the item was
emitted by the source Observable.
Sample Code
var source = Rx.Observable.timer(0, 1000)
.timestamp()
.map(function (x) { return x.value + ':' + x.timestamp; })
.take(5);
var subscription = source.subscribe(
function (x) { console.log('Next: ' + x); },
function (err) { console.log('Error: ' + err); },
function () { console.log('Completed'); });
Next: 0:1378690776351
Next: 1:1378690777313
Next: 2:1378690778316
Next: 3:1378690779317
Next: 4:1378690780319
Completed
timestamp
by default operates on the timeout
Scheduler, but also has a
variant that allows you to specify the Scheduler by passing it in as a parameter.
timestamp
is found in each of the following distributions:
rx.all.js
rx.all.compat.js
rx.time.js
(requires rx.js
or rx.compat.js
)
rx.lite.js
rx.lite.compat.js