Skip to main content

setInterval()

setInterval() executes a callback function with a fixed time interval between the calls.

Signature

setInterval(callbackFunction: Function, interval: number, id?: string, args?: any)

Parameters

callbackFunction

The function or code snippet that you want to execute at regular intervals.

interval

The time interval (in milliseconds) between each execution of the callbackFunction.

id

id accepts a string name that you can use to refer to an interval timer. When calling clearInterval(), pass this string name as the id parameter to stop the interval timer.

Example: If you want to execute Query1 every 1000 milliseconds and refer to this timer as myTimer, you can achieve this using the code snippet given below:

setInterval(() => { Query1.run() }, 10000, "myTimer");

See also