forked from richardszalay/raix
-
Notifications
You must be signed in to change notification settings - Fork 0
timestamp
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>
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.
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
Unless specified, Scheduler.synchronous
will be used to determine the current time
IObservable.<TimeStamped>
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
// ...