-
• #2
Looks like
alarm.js
is only called fromboot.js
which is run at boot time. What else you think would be running at that time?EDIT: Just ignore this, I didn't realize there is potentially long
setTimeout
inboot.js
- so yes good question. -
• #3
Would an immediate run not still pose problems for something earlier in the boot process?
-
• #4
Hi,
As noted, I think
alarm.js
is only called when an alarm is due, and it is called withload(...)
so everything else is removed at that point and it's just theboot.js
code that is run.Reasoning for it is in the comments above it:
// Chances are boot0.js got run already and scheduled *another* // 'load(alarm.js)' - so let's remove it first! clearInterval();
I'm not sure it's really a huge issue as it would only ever affect things in the case the alarm actually goes off. Are you actually having issues and you think that might be the cause?
I guess now we have
__FILE__
defined,boot.js
could check that instead and just not schedule an alarm ifglobal.__FILE__=="alarm.js"
-
• #5
Are you actually having issues and you think that might be the cause?
Not that I'm aware of. I intend to make timer app that can run in the background so I was trying to understand understand what exactly the alarm app does and why it does.
As noted, I think alarm.js is only called when an alarm is due, and it is called with load(...) so everything else is removed at that point and it's just the boot.js code that is run.
Does that mean that the clearInterval effectively only applies until alarm.js is done? That certainly would make it very unlikely to impact pending timeouts... I may have been more confused about how often boot actually runs in that case.
Is there some distinction between boot.js and boot0.js that could lead to another load of alarm.js? Or is there some some special handling of all alarm.js files as hinted in the BangleApps Readme (although I couldn't really find any more on that) that may affect it?
I may be overthinking things...
-
• #6
I intend to make timer app that can run in the background
Is there any chance you could just use/update the existing alarm app - since that handles timers too? You could then just make your app update
alarm.json
with the timers it wants scheduled.Does that mean that the clearInterval effectively only applies until alarm.js is done?
Yes, that's right - because alarm.js either uses
load
to load another app straight away, or is displays a fullscreen message.another load of alarm.js?
No, I don't think so... Once
load(...)
is called it's like a complete restart - it gets rid of everything and starts from scratch
I've been studying the alarm app and can not figure out how alarm.js can safely call clearInterval without affecting everything else that may be using timers or intervals. Is there something about the bangle architecture I'm missing that limits the impact of clearInterval?