jsish
Events
Not logged in

Schedule

function setTimeout(callback:function, millisecs:number):number
function setInterval(callback:function, millisecs:number):number
function clearInterval(id:number):void

Events are scheduled using setTimeout/setInterval/clearInterval, just as in ecmascript.

One difference is that we need to explicitly call update() so that events will be serviced:

function foo() {
    puts("FOO:");
}
setInterval(foo, 1000);
update(-1);

The call to update(-1) causes foo to be called once a second.


Update

function update(options:number|object=void):number

update processes scheduled events.

OptionDescription
maxEventsMaximum number of events to process
maxPassesMaximum passes through event queue
minTimeMinimum milliseconds before returning, or -1 to loop forever (Default is 0)
sleepSleep time between event checks in milliseconds (Default is 1)

Events are processed until one of minTime, maxEvents, or maxPasses is exceeded.

The returned value is the number of events processed.

For more details see Reference


Info

Info.event = function (id:number=void):array|object

In Jsi we can use Info.event() to query queued events:

function foo() {
    puts("FOO: " + i++);
    if (i>=3) exit(0);
}
var i=0, id = setInterval(foo,1000);
var evs = Info.event();
for (var i in evs) {
  puts('EV(' + i + '): ' + Info.event(evs[i]).toString());
}
update();
EV(0): { builtin:false, count:0, initial:1000, once:false, type:"timer", when:1000 }
FOO: 0
FOO: 1
FOO: 2

This returns value is:

For more details see Info