API Docs

Object representing a timer. You should not instantiate these yourself, but rather, use the methods in hs.timer to create them for you.

Properties

interval

number
The timer's interval in seconds

repeats

boolean
Whether the timer repeats

Methods

start() -> None

Start the timer
start() -> None
None
const t = hs.timer.new(5, () => console.log("tick"), false)
t.start()

stop() -> None

Stop the timer
stop() -> None
None
const t = hs.timer.doEvery(5, () => {})
t.stop()

fire() -> None

Immediately fire the timer's callback
fire() -> None
None
const t = hs.timer.doEvery(5, () => console.log("tick"))
t.fire()

running() -> boolean

Check if the timer is currently running
running() -> boolean
boolean
true if the timer is running, false otherwise
const t = hs.timer.doEvery(5, () => {})
console.log(t.running())

nextTrigger() -> number

Get the number of seconds until the timer next fires
nextTrigger() -> number
number
Seconds until next trigger, or a negative value if the timer is not running
const t = hs.timer.doEvery(5, () => {})
console.log(t.nextTrigger())

setNextTrigger(seconds) -> None

Set when the timer should next fire
setNextTrigger(seconds) -> None
Name Type Description
seconds number Number of seconds from now when the timer should fire
None
const t = hs.timer.doEvery(5, () => {})
t.setNextTrigger(10)