12-27-2019 08:12 - edited 12-27-2019 08:13
12-27-2019 08:12 - edited 12-27-2019 08:13
Hey there!
So I'm developing a clock face and am currently looking for a way to ensure an event is ran every hour, preferably on the hour (:00).
The ontick event does not run while the display is asleep, so this isn't ideal...
I was considering setting an setTimeout event when the display gets turned off, with the duration being set to how long is remaining until the new hour. Would this work? If not, is there any way to achieve what I'm looking for?
12-27-2019 11:53
12-27-2019 11:53
That's the best you can do. Just be aware that if the user isn't running your app at the top of the hour, the timeout won't occur. You might want to keep track of when the previous timeout occurred so that, when your app starts, you can detect whether it's been over an hour and take appropriate measures.