• 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)}
              ]
            });
    
  • 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?

About

Avatar for Gordon @Gordon started