You are reading a single comment by @gfric and its replies. Click here to read the full conversation.
  • Thank you.
    When I receive a message in

    Bangle.on("message", (type, msg) => require("xxlmessage").listener(type, msg));
    

    and I want to show a scrolling message, I need a timeout for the redraw, and a variable holding the current scroll position.
    So I can make a global variable like:

    var scrollPosition=0;
    var scrollTimeout;
    exports.messageListener = function(type, msg) {
    }
    

    Now, when I exit this code, by calling load(), will the global variables 'scrollPosition' etc. be freed from memory?
    Also, can I break things, if my global variables have names that are used in other apps or the system?
    I ask, because this code is in boot.js and thus always loaded. Will 'require()' load the js file on demand? What is the variable scope? The scope of require(), or global?

About

Avatar for gfric @gfric started