HSTimer
TypeObject representing a timer. You should not instantiate these yourself, but rather, use the methods in hs.timer to create them for you.
Properties
Methods
start() -> None
Start the timer
Declaration
start() -> None
Returns
None
Example
const t = hs.timer.new(5, () => console.log("tick"), false)
t.start()
stop() -> None
Stop the timer
Declaration
stop() -> None
Returns
None
Example
const t = hs.timer.doEvery(5, () => {})
t.stop()
fire() -> None
Immediately fire the timer's callback
Declaration
fire() -> None
Returns
None
Example
const t = hs.timer.doEvery(5, () => console.log("tick"))
t.fire()
running() -> boolean
Check if the timer is currently running
Declaration
running() -> boolean
Returns
boolean
true if the timer is running, false otherwise
Example
const t = hs.timer.doEvery(5, () => {})
console.log(t.running())
nextTrigger() -> number
Get the number of seconds until the timer next fires
Declaration
nextTrigger() -> number
Returns
number
Seconds until next trigger, or a negative value if the timer is not running
Example
const t = hs.timer.doEvery(5, () => {})
console.log(t.nextTrigger())
setNextTrigger(seconds) -> None
Set when the timer should next fire
Declaration
setNextTrigger(seconds) -> None
Parameters
| Name | Type | Description |
|---|---|---|
| seconds | number | Number of seconds from now when the timer should fire |
Returns
None
Example
const t = hs.timer.doEvery(5, () => {})
t.setNextTrigger(10)