The timer
module exposes a global API for scheduling functions to be called at some future period of time. Because the timer functions are globals, there is no need to call require('timers') to use the API.
callback
{Function} The function to call when the timer elapses.
...args
{any}delay
{number} The number of milliseconds to wait before calling the callback
....args
{any} - Optional arguments to pass when the callback
is called.Schedules execution of a one-time callback
after delay
milliseconds. Returns a Timeout
for use with clearTimeout()
. If callback
is not a function, a TypeError
will be thrown.
Example
var timeout = setTimeout(function() {
// Do something which will be executed after one second.
}, 1000);
timeout
{Timeout} A Timeout object returned by setTimeout()
.Cancels a Timeout
object created by setTimeout()
.
Example
var timeout = setTimeout(function() { }, 1000);
...
clearTimeout(timeout);
callback
{Function} The function to call when the timer elapses.
...args
{any}delay
{number} The number of milliseconds to wait before calling the callback
....args
{any} - Optional arguments to pass when the callback
is called.Schedules repeated execution of callback
every delay
milliseconds. Returns a Timeout
object for use with clearInterval()
. If callback
is not a function, a TypeError
will be thrown.
Example
var timeout = setInterval(function() {
// Do something which will be executed repeatadly one time per second.
}, 1000);
timeout
{Timeout} A Timeout object as returned by setInterval()
.Cancels a Timeout
object created by setInterval()
.
Example
var timeout = setInterval(function() { }, 1000);
...
clearInterval(timeout);
This object is created internally and is returned from setTimeout()
and setInterval()
.
When called, requests that the IoT.js event loop should not exit as long as the Timeout
is active.
When called, the active Timeout
object will not force the IoT.js event loop to remain active. If there are no other scheduled activities, the process may exit, the process may exit before the Timeout
object's callback is invoked.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。