Skip to main content

Timer

API for creating and managing timers.

Functions

Timer.setInterval

Creates a timer which calls the function continuously with the given delay.

Timer.setInterval(duration: number, callback: function): number

Parameters

NameTypeDefault ValueDescription
durationnumberRequiredThe time between function calls (in seconds).
callbackfunctionRequiredThe function to call at each interval.

Returns

NameTypeDescription
idnumberThe ID of the timer.

Timer.setTimeout

Creates a timer which calls the function once after the given delay.

Timer.setTimeout(duration: number, callback: function): number

Parameters

NameTypeDefault ValueDescription
durationnumberRequiredThe delay before calling the function (in seconds).
callbackfunctionRequiredThe function to call after the timeout.

Returns

NameTypeDescription
idnumberThe ID of the timer.

Timer.clear

No description provided.

Timer.clear(id: number)

Parameters

NameTypeDefault ValueDescription
idnumberRequiredThe ID of the timer to clear.