Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

setInterval - how it works?

ANSWERED

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.

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

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).

Peter McLennan
Gondwana Software

View best answer in original post

Best Answer
0 Votes
2 REPLIES 2

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).

Peter McLennan
Gondwana Software
Best Answer
0 Votes

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.

Best Answer