Henry, a good/save/robust practice is to have an onInit() { ... } function that gets everything going on power cycle... Having active code - in level 0 - is executed on upload and can be challenging. Take a look at simple explanation how to save code that espruino run on start?.
Furthermore, below things give me a bit the chill... because this can actually mess with the Espruino platform which may already include running JS (boot code that uses watches, and timers). To avoid having to go with the crow bar but still want to be able to 'cleanup after me-code' or have in the application the need to stop or pause these hw and sw events/hooks, ,I use variables to hold on to the watch, timeout and interval handles and then use them in the clear functions.
clearWatch();
clearTimeout();
clearInterval();
What code distribution topology to chose? ...it all depends. The pendulum is always swinging and a hybrid approach feels to me right. Question is: what and where are 'your' pain points? There is allways pain - never no pain - but minimizing it by optimizing is the virtue.
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.
Henry, a good/save/robust practice is to have an
onInit() { ... }
function that gets everything going on power cycle... Having active code - in level 0 - is executed on upload and can be challenging. Take a look at simple explanation how to save code that espruino run on start?.Furthermore, below things give me a bit the chill... because this can actually mess with the Espruino platform which may already include running JS (boot code that uses watches, and timers). To avoid having to go with the crow bar but still want to be able to 'cleanup after me-code' or have in the application the need to stop or pause these hw and sw events/hooks, ,I use variables to hold on to the watch, timeout and interval handles and then use them in the clear functions.
What code distribution topology to chose? ...it all depends. The pendulum is always swinging and a hybrid approach feels to me right. Question is: what and where are 'your' pain points? There is allways pain - never no pain - but minimizing it by optimizing is the virtue.