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: fun()): number

Parameters

NameTypeDescription
durationnumberThe time between function calls (in seconds).
callbackfun()The 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: fun()): number

Parameters

NameTypeDescription
durationnumberThe delay before calling the function (in seconds).
callbackfun()The function to call after the timeout.

Returns

NameTypeDescription
idnumberThe ID of the timer.

Timer.clear

No description provided.

Timer.clear(id: number)

Parameters

NameTypeDescription
idnumberThe ID of the timer to clear.