ZJS provides the familiar setTimeout and setInterval interfaces. They are always available.
This IDL provides an overview of the interface; see below for documentation of specific API functions. We have a short document explaining ZJS WebIDL conventions.
Click to show WebIDL
// require returns a Timers object // var timers = require('timers'); [ReturnFromRequire] interface Timers { intervalID setInterval(TimerCallback func, unsigned long delay, any... args_for_func); timeoutID setTimeout(TimerCallback func, unsigned long delay, any... args_for_func); void clearInterval(long intervalID); void clearTimeout(long timeoutID); };callback TimerCallback = void (any... callback_args);
typedef long timeoutID; typedef long intervalID;
func
TimerCallback A callback function that will take the arguments passed in the variadicargs_for_func
parameter.delay
unsigned long Thedelay
argument is in milliseconds. Currently, the delay resolution is about 10 milliseconds, and if you choose a value less than that it will probably fail.args_for_func
any The user can pass an arbitrary number of additional arguments that will then be passed tofunc
.- Returns: an
intervalID
value that can be passed toclearInterval
to stop the timer.
Every delay
milliseconds, your callback function will be called.
func
TimerCallback A callback function that will take the arguments passed in the variadicargs_for_func
parameter.delay
unsigned long Thedelay
argument is in milliseconds. Currently, the delay resolution is about 10 milliseconds.args_for_func
any The user can pass an arbitrary number of additional arguments that will then be passed tofunc
.- Returns: a
timeoutID
that can be passed toclearTimeout
to stop the timer.
After delay
milliseconds, your callback function will be called one time.
intervalID
long This value was returned from a call tosetInterval
.
That interval timer will be cleared and its callback function no longer called.
timeoutID
long This value was returned from a call tosetTimeout
.
The timeoutID
timer will be cleared and its callback function will not be
called.