{ "source": "doc/api/timers.markdown", "modules": [ { "textRaw": "Timers", "name": "timers", "stability": 3, "stabilityText": "Locked", "desc": "
All of the timer functions are globals. You do not need to require()
\nthis module in order to use them.\n\n
To schedule execution of a one-time callback
after delay
milliseconds. Returns a\ntimeoutObject
for possible use with clearTimeout()
. Optionally you can\nalso pass arguments to the callback.\n\n
It is important to note that your callback will probably not be called in exactly\ndelay
milliseconds - io.js makes no guarantees about the exact timing of when\nthe callback will fire, nor of the ordering things will fire in. The callback will\nbe called as close as possible to the time specified.\n\n
Prevents a timeout from triggering.\n\n
\n", "signatures": [ { "params": [ { "name": "timeoutObject" } ] } ] }, { "textRaw": "setInterval(callback, delay[, arg][, ...])", "type": "method", "name": "setInterval", "desc": "To schedule the repeated execution of callback
every delay
milliseconds.\nReturns a intervalObject
for possible use with clearInterval()
. Optionally\nyou can also pass arguments to the callback.\n\n
Stops an interval from triggering.\n\n
\n", "signatures": [ { "params": [ { "name": "intervalObject" } ] } ] }, { "textRaw": "unref()", "type": "method", "name": "unref", "desc": "The opaque value returned by setTimeout
and setInterval
also has the method\ntimer.unref()
which will allow you to create a timer that is active but if\nit is the only item left in the event loop, it won't keep the program running.\nIf the timer is already unref
d calling unref
again will have no effect.\n\n
In the case of setTimeout
when you unref
you create a separate timer that\nwill wakeup the event loop, creating too many of these may adversely effect\nevent loop performance -- use wisely.\n\n
If you had previously unref()
d a timer you can call ref()
to explicitly\nrequest the timer hold the program open. If the timer is already ref
d calling\nref
again will have no effect.\n\n
To schedule the "immediate" execution of callback
after I/O events\ncallbacks and before setTimeout
and setInterval
. Returns an\nimmediateObject
for possible use with clearImmediate()
. Optionally you\ncan also pass arguments to the callback.\n\n
Callbacks for immediates are queued in the order in which they were created.\nThe entire callback queue is processed every event loop iteration. If you queue\nan immediate from inside an executing callback, that immediate won't fire\nuntil the next event loop iteration.\n\n
\n", "signatures": [ { "params": [ { "name": "callback" }, { "name": "arg", "optional": true }, { "name": "...", "optional": true } ] } ] }, { "textRaw": "clearImmediate(immediateObject)", "type": "method", "name": "clearImmediate", "desc": "Stops an immediate from triggering.\n
\n", "signatures": [ { "params": [ { "name": "immediateObject" } ] } ] } ], "type": "module", "displayName": "Timers" } ] }