Converting code to use the fastload properly

Posted on
  • Current code attached.

    When I change

    var drawTimeoutSeconds;
    to
    let drawTimeoutSeconds;
    

    in Line 123,

        if (drawTimeoutSeconds) clearTimeout(drawTimeoutSeconds);
    

    it does work when I open the launcher from the watchface. But when I get back to the watchface and open the launcher AGAIN, drawTimeoutSeconds seems to be undefined (and the seconds run behind the launcher) and the Timeout doesn't get cleared.

    Any suggestions what I'm doing wrong here?


    1 Attachment

  • Have you seen http://www.espruino.com/Bangle.js+Fast+L­oad ?

    I can see you're still defining function queueDraw()/etc when you need to be doing let queueDraw = function() { ...} (for all functions in the global scope) so that might be causing you trouble

  • EDIT: Gordon beat me to it.

  • Sorry, still learning. How does this work if I want to pass something to the function?

    function doublenum(x) {
    

    will that be like

    let doublenum= function(x) {
    

    ?

  • Sorted it out. Looks if it is working so far. Thanks a million!

  • Current code attached (the bottom one) . There seems to still be a memory leak issue. Any advice?

    Do I need to do something like

    	delete queueDraw;
    	delete def;
    	delete queueDrawSeconds;
    	delete doublenum;
    	delete draw;
    	delete drawSeconds;
    	delete getCurrentTimeFromOffset;
    	delete updatePos;
    	delete secondsMode;
     // etc.
    

    ?


    2 Attachments

  • You shouldn't need to delete stuff if it was defined with let/const inside a {}.

    Are you sure it's not modules? see http://www.espruino.com/Bangle.js+Fast+L­oad#testing-afterwards

    All I can suggest is to maybe look at Object.keys(global) and see if there's anything there that shouldn't be

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Converting code to use the fastload properly

Posted by Avatar for Hank @Hank

Actions