12-17-2021 09:22
12-17-2021 09:22
Hey,
I'm currently creating yet another clock and I need to show the current time in a label based on a toggle in my settings page.
Sounds easy but my clock granularity is set to minutes so my user would have to wait up to ~59 seconds to see the changes.
Is there any way to kinda fire a new tick event programatically?
Best regards,
wrnr
Answered! Go to the Best Answer.
12-17-2021 11:47
12-17-2021 11:47
There are many ways; here's mine. You can direct the clock.ontick event handler to a named function like this:
clock.ontick = evt => {onTick(evt.date)}
You declare your handler function like this:
function onTick(now) {...
When you need that function to run because you've changed something on which it depends (eg, setting):
onTick(new Date())
12-17-2021 11:47
12-17-2021 11:47
There are many ways; here's mine. You can direct the clock.ontick event handler to a named function like this:
clock.ontick = evt => {onTick(evt.date)}
You declare your handler function like this:
function onTick(now) {...
When you need that function to run because you've changed something on which it depends (eg, setting):
onTick(new Date())
12-17-2021 13:58
12-17-2021 13:58
Thank you! This works