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

Creates an unending observable sequence of integers, starting from 0 after delayMs milliseconds, and incrementing every intervalMs milliseconds.

static function timer(delayMs : uint, intervalMs : uint, 
    scheduler : IScheduler = null) : IObservable.<int>

Remarks

The returned sequence does not complete

The returned sequence does not error

Marble Diagrams

│delayMs│intervalMs│intervalMs│
────────o──────────o──────────o──────────o──>
        0          1          2    ...   ∞

Scheduling

Unless specified, this operator uses Scheduler.synchronous.

Return Value

IObservable.<int>

Examples

var elapsedTime : uint = 0;

Observable.timer(500, 1000)
    .subscribe(function(index : int) : void
    {
        elapsedTime += index;
        trace(elapsedTime + " - " + index);
    });

    // Trace output is:
    // 500 - 0
    // 1500 - 1
    // 2500 - 2
    // 3500 - 3
    // ...
Clone this wiki locally