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
clearTimeout
setInterval
clearInterval

Functions

setTimeout
Starts a timer that will fire once.

Parameters

function callbackThe function that shall be called when the timer fires.
unsigned millisecondsThe number of milliseonds after which the timer should fire.

Return value

timeoutReferenceA 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 referenceThe reference that was returned by setTimeout.
Timers.clearTimeout(t);
setInterval
Starts an interval timer that will periodically fire until it is stopped.

Parameters

function callbackThe function that shall be called every time the interval timer fires.
unsigned millisecondsThe number of milliseonds after which the interval timer should periodically elapse.

Return value

intervalReferenceA 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 referenceThe reference that was returned by setInterval.
Timers.clearInterval(i);