interface.html: Controlling the current Bangle.js app #7759
-
I've got together a working interface.html that provides an alternate way of editing the timer definitions in the app I'm working on. But I just discovered by accident that it's possible to click the Save Timers button in this interface while the timer app is currently running on the Bangle.js. The app doesn't know about the updated timers file just pushed to the device, so it retains the old data in memory and ends up overwriting the new data just pushed. Is there a way to ensure the app is not running when this happens, e.g. by forcing it to exit before sending the timers file, so that when it's loaded again it picks up the new data properly? The most obvious idea would be to send a |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
You could use something like ... or what about writing your updated timer file and then doing something like:
Where |
Beta Was this translation helpful? Give feedback.
-
Thanks! I think loading entirely out of the app is the simplest and safest way for now. But I'm sporadically getting a weird error in the console. This is the code I tried:
The Bangle console looks like this:
It appears the app exits, and the file appears to get sent successfully, but then this |
Beta Was this translation helpful? Give feedback.
-
I think it's because you're not writing a newline in the Puck.write call (see the code I posted above) so the code isn't executing immediately. I imagine it executes only when the next command is sent (for the file upload?) some time later - so you're getting all kinds of crazy errors when the Bangle reloads halfway through uploading the file? |
Beta Was this translation helpful? Give feedback.
-
Ah thanks, that seems really obvious now. Yeah, adding the newline seems to work properly. |
Beta Was this translation helpful? Give feedback.
You could use something like
Puck.write("if (global.__FILE__=='myapp.app.js')load()\n", callback)
and then delay a bit as you suggest to load out of your app if you were in it.... or what about writing your updated timer file and then doing something like:
Where
reloadMyTimers()
is a function in your app that'll cause it to reload the data that you just wrote?