I've tried to write a clock module, but it needs to do an internal setInterval to call an internal function. I tried to setInterval(this.tick,1000) but it fails.
I think I found some example code - this defines the function to be called by setInterval in the exported init function - which I think means it will be cloned every time the class is used - which wastes memory a bit.
Is there any way to have a module function that is called by setInterval...?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi
I've tried to write a clock module, but it needs to do an internal setInterval to call an internal function. I tried to setInterval(this.tick,1000) but it fails.
I think I found some example code - this defines the function to be called by setInterval in the exported init function - which I think means it will be cloned every time the class is used - which wastes memory a bit.
Is there any way to have a module function that is called by setInterval...?
Thanks
Martin