Skip to content
richardszalay edited this page May 20, 2011 · 5 revisions

Outputs the original value wrapped in a TimeStamped object which adds the time at which value was emitted. To remove the timestamp, see [removeTimestamp]

function timestamp(scheduler : IScheduler = null) : IObservable.<TimeStamped>

Remarks

The timestamp property of TimeStamped is a Number. To work with a Date object, pass the timestamp value to the Date constructor.

The returned sequence completes when the source sequence completes.

The returned sequence raises an error if the source sequence raises an error.

Marble Diagrams

x,now = TimeStamped with x as value and the current time as timestamp

xs    ──o─────o─────o───/
        │     │     │   │
        │     │     │   │
ys    ──o─────o─────o───/
       x,now x,now x,now

Scheduling

Unless specified, Scheduler.synchronous will be used to determine the current time

Return Value

IObservable.<TimeStamped>

Examples

Observable.interval(1000).timestamp()
    .subscribe(
        function(ts : TimeStamped) : void { trace(ts.value.toString() + " - " + ts.timestamp.toString()); }
    );

    // Trace output is:
    // 0 - 1277838171417
    // 1 - 1277838172417
    // 2 - 1277838173417
    // 3 - 1277838174417
    // 4 - 1277838175417
    // 5 - 1277838176417
    // 6 - 1277838177417
    // ...
Clone this wiki locally