10-17-2020 10:12
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


10-17-2020 10:12
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Can anyone explain how the setInterval works in the following conditions.
In a clock app issue a setInterval - then switch to another app, Today or exercise.
Return to the original app some time after the interval has expired.
What happens to the interval, is it lost, does it hang around, will it trigger the original app in some way even though another app is running at the time? Does it do anything else? Does one have to remove it, even though it passed? Any other special considerations?
Without a full understanding its not possible to determine if it could be causing problems.
Thanks
Author | ch, passion for improvement.
Answered! Go to the Best Answer.

Accepted Solutions
10-17-2020 13:05
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


10-17-2020 13:05
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I don't think your question is really about setInterval. It's about how JavaScript runs on the watch. When another app is started, your clockface is closed (ie, killed, not just invisible). That means all JavaScript 'state' associated with it (eg, variables and intervals) is lost. The only thing retained is any info you've written to the file system.
When your clockface resumes, it's like starting again for the first time (except that it could load info from the file system if it placed any there previously).
Gondwana Software

10-17-2020 13:05
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


10-17-2020 13:05
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I don't think your question is really about setInterval. It's about how JavaScript runs on the watch. When another app is started, your clockface is closed (ie, killed, not just invisible). That means all JavaScript 'state' associated with it (eg, variables and intervals) is lost. The only thing retained is any info you've written to the file system.
When your clockface resumes, it's like starting again for the first time (except that it could load info from the file system if it placed any there previously).
Gondwana Software

10-17-2020 13:17
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


10-17-2020 13:17
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Thanks Peter.
That was what I thought.
I just wanted to make sure that's how it worked and there were no hidden issues to be taken care of.
Author | ch, passion for improvement.
