Timestamp

attach a timestamp to each item emitted by an Observable indicating when it was emitted

Timestamp

The Timestamp operator attaches a timestamp to each item emitted by the source Observable before reemitting that item in its own sequence. The timestamp indicates at what time the item was emitted.

See Also

Language-Specific Information:

timestamp

The timestamp method converts an Observable that emits items of type T into one that emits objects of type Timestamped<T>, where each such object is stamped with the time at which it was originally emitted.

def myObservable = Observable.range(1, 1000000).filter({ 0 == (it % 200000) });

myObservable.timestamp().subscribe(
  { println(it.toString()); },               // onNext
  { println("Error: " + it.getMessage()); }, // onError
  { println("Sequence complete"); }          // onCompleted
);
Timestamped(timestampMillis = 1369252582698, value = 200000)
Timestamped(timestampMillis = 1369252582740, value = 400000)
Timestamped(timestampMillis = 1369252582782, value = 600000)
Timestamped(timestampMillis = 1369252582823, value = 800000)
Timestamped(timestampMillis = 1369252582864, value = 1000000)
Sequence complete

timestamp by default operates on the computation Scheduler but also has a variant that allows you to choose the Scheduler by passing it in as a parameter.

timestamp

The timestamp method converts an Observable that emits items of type T into one that emits objects of type Timestamped<T>, where each such object is stamped with the time at which it was originally emitted.

timestamp by default operates on the computation Scheduler but also has a variant that allows you to choose the Scheduler by passing it in as a parameter.

timestamp

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

RxPHP implements this operator as timestamp.

Records the timestamp for each value in an observable sequence.

Sample Code

//from https://github.com/ReactiveX/RxPHP/blob/master/demo/timestamp/timestamp.php

$source = \Rx\Observable::interval(1000)
    ->timestamp()
    ->map(function (\Rx\Timestamped $x) {
        return $x->getValue() . ':' . $x->getTimestampMillis();
    })
    ->take(5);

$source->subscribe($createStdoutObserver());

// Next value: 0:1460781738354
// Next value: 1:1460781739358
// Next value: 2:1460781740359
// Next value: 3:1460781741362
// Next value: 4:1460781742367
// Complete!

   
Next value: 0:1489535638531
Next value: 1:1489535639534
Next value: 2:1489535640532
Next value: 3:1489535641528
Next value: 4:1489535642528
Complete!
    

TBD