-
Notifications
You must be signed in to change notification settings - Fork 8
timeInterval
richardszalay edited this page May 20, 2011
·
13 revisions
Outputs the original value wrapped in a TimeInterval object which adds the amount of time that passed since the previous value was emitted. To remove the interval, see [removeTimeInterval]
function timeInterval(scheduler : IScheduler = null) : IObservable.<TimeInterval>
The returned sequence completes when the source sequence completes.
The returned sequence raises an error if the source sequence raises an error.
ts1, ts2 = time between values
x,<interval> = TimeInterval with x as value and <interval> as interval
xs ──o─────o─────o───/
│ ti1 │ ti2 │ │
│-----│-----│---│
ys ──o─────o─────o───/
x,0 x,ti1 x,ti2
Unless specified, Scheduler.synchronous
will be used to determine the current time
IObservable.<TimeInterval>
Observable.interval(1000)
.subscribe(function(i : int) : void
{
trace(ti.toString());
});
// Trace output is:
// 0 (@ 00:00:01)
// 1 (@ 00:00:02)
// 2 (@ 00:00:03)
// 3 (@ 00:00:04)
// ...