-
Notifications
You must be signed in to change notification settings - Fork 8
timer
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>
The returned sequence does not complete
The returned sequence does not error
│delayMs│intervalMs│intervalMs│
────────o──────────o──────────o──────────o──>
0 1 2 ... ∞
Unless specified, this operator uses Scheduler.synchronous
.
IObservable.<int>
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
// ...