Timers
This document describes the Timers object in the JavaScript environment for app serivices. It provides timer and interval timer functionality.
Table of content
Functions
setTimeout
Starts a timer that will fire once.
Parameters
function callback | The function that shall be called when the timer fires. |
unsigned milliseconds | The number of milliseonds after which the timer should fire. |
Return value
timeoutReference | A reference that can be used for stopping the timer using clearTimeout. |
var t = Timers.setTimeout(function() {
log("timeout after one second!");
}, 1000);
clearTimeout
Stops a timer.
Parameters
timeoutReference reference | The reference that was returned by setTimeout. |
Timers.clearTimeout(t);
setInterval
Starts an interval timer that will periodically fire until it is stopped.
Parameters
function callback | The function that shall be called every time the interval timer fires. |
unsigned milliseconds | The number of milliseonds after which the interval timer should periodically elapse. |
Return value
intervalReference | A reference that can be used for stopping the interval timer using clearInterval. |
var i = Timers.setInterval(function() {
log("another second has passed!");
}, 1000);
clearInterval
Stops an interval timer.
Parameters
intervalReference reference | The reference that was returned by setInterval. |
Timers.clearInterval(i);