Skip to content
richardszalay edited this page Sep 14, 2010 · 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

function timeInterval(type : Class, scheduler : IScheduler = null) : IObservable

Remarks

The returned sequence completes when the source sequence completes.

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

Marble Diagrams

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

Scheduling

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

Return Value

IObservable.<TimeInterval>

Examples

Observable.interval(1000).timeInterval()
    .subscribe(
        function(ti : TimeInterval) : void { trace(ti.value.toString() + " - " + ti.interval.toString()); }
    );

    // Trace output is:
    // 0 - 1000
    // 1 - 1000
    // 2 - 1000
    // 3 - 1000
    // ...
Clone this wiki locally