Skip to content

Latest commit

 

History

History
29 lines (19 loc) · 944 Bytes

intervals-time-events.md

File metadata and controls

29 lines (19 loc) · 944 Bytes

Intervals (Time events)

Interval events (Timing functions in JavaScript) allow the user to periodically run APIs and DB queries. You can configure these by using the setInterval and clearInterval functions.

{% embed url="https://youtu.be/ByE3aqlQ1pE" %}

setInterval()

The setInterval() method executes a code snippet with a fixed time interval between the calls, i.e, it executes a trigger callback at a given interval. Here’s how you can use it while dynamically binding queries onto widgets:

//Syntax 
setInterval(callbackFunction: Function, interval: number, id?: string)

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

clearInterval()

The clearInterval() function stops executing the trigger callback started with the setInterval method.

//Syntax
clearInterval(id: string)

// Example 
clearInterval("myTimer");