-
• #2
Ahh, so you have two issues I think...
If you try this as an example in the Web Browser:
const data = { txtTest1: 1, txtTest2: 2 }; console.log(`require("Storage").writeJSON("timerdat.json",${data})`);
You get:
require("Storage").writeJSON("timerdat.json",[object Object])
So what you actually need is to convert the object to JSON first:
const data = { txtTest1: 1, txtTest2: 2 }; console.log(`require("Storage").writeJSON("timerdat.json",${JSON.stringify(data)})`);
However, the
custom
app page doesn't have anything to communicate with a Bangle.js at the moment. However nothing stops you from sending whatever data you want - that's what the custom page is for...For instance in https://github.com/espruino/BangleApps/blob/master/apps/beer/beercompass.html#L203
You just do:
sendCustomizedApp({ storage:[ {name:"timerdat.json", content:JSON.stringify(data)} ] });
-
• #3
thanks for your help. the trick with the storage json file works.
have you any plans to add the communication with a Bangle.js like for the interface page? i would love to simply load and save user settings for my app or clock. I think the current approach to write the whole Bangle.js app as a template string inside the custom page like this (https://github.com/espruino/BangleApps/blob/master/apps/beer/beercompass.html#L126-L198) is not really suitable for complex apps. Maybe we could add the same onInit() hook for custom pages!? what did you think?
-
• #4
I think the current approach to write the whole Bangle.js app as a template string is not really suitable for complex apps
Yes, totally. In fact I just chose that as a quick example but I think for newer stuff we're just sending a config JSON and then having the app itself as a separate file (which you can reference from apps.json as normal).
have you any plans to add the communication with a Bangle.js like for the interface page?
Is there a reason for not adding an
interface.html
file as well? The idea of the customizer is to get called when the app is uploaded.As I understand it, right now in order to start the customizer you have to have deleted your app first (apart from when updating) so if the app loader was set up right everything from your app should already have been deleted?
-
• #5
@Gordon i have implemented the onInit() hook for custom pages. See here https://github.com/flashback2k14/BangleApps/blob/master/js/index.js#L78-L128.
If you like it i could open a PR!?
-
• #6
If you can do it in a way that doesn't duplicate a bunch of code then sure - but as I mentioned it'll still only work when installing (not when already installed).
If you'll then want to enable it so you can run whenever you want, I think you probably should have been making an interface.html all along :)
-
• #7
i think now i got the intension for the custom page. :-) it's maybe a little bit misleading. The interface page is now the preferred way.
But i think a third option should be introduced. A settings page with its own icon, tooltip and behavior. What did you think?
-
• #8
So how would the behaviour of the third icon be different to the 'interface' page, apart from having a different icon?
If we can avoid adding more complexity that seems preferable. In an ideal world we'd be able to combine custom/interface together.
I'm all for changing the existing icon/tooltip of the interface page - up arrow vs down arrow is pretty confusing (it's just what spectre.css had built in), and something that showed 'communication/settings' better would be ideal.
Also there's no reason that the 'interface' couldn't appear in the App Loader even before the watch was connected. It'd then connect and if the app wasn't installed, it would install it and then run the interface page.
hello,
is it possible to send or save data to a connected bangle.js inside a custom page?
here is my code: https://github.com/flashback2k14/BangleApps/tree/master/apps/timer.
i want to send data to the bangle.js, but this is not working. see here: https://github.com/flashback2k14/BangleApps/blob/master/apps/timer/timer-custom.html#L22
config: https://github.com/flashback2k14/BangleApps/blob/master/apps.json#L2573
thanks in advance.