-
Notifications
You must be signed in to change notification settings - Fork 13
Timer
Lauri-Matti Parppei edited this page Feb 18, 2022
·
2 revisions
When using a resident plugin (a plugin that remains running in background), you can set timers to fire after a given timeout.
A plugin that doesn't have a listener or some other way of staying in memory will not be able to run timers.
let timer = Beat.timer(seconds, callback, repeat)timer.invalidate() — stop and remove the timer from memory
timer.stop() — stop and reset the timer
timer.start() — restart the timer
timer.running() – check if the timer is currently running
When repeat is set to true the timer will stay in memory. It defaults to false, so you can create one-off timeouts, too:
Beat.timer(1.0, function () {
Beat.log("One second elapsed.")
})