But personally if you can I'd just make sure you only call Puck.on('mag', once - there's no need to call it at startup each time because Espruino will remember.
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.
If you have the function handy you can do
Puck.removeListener('mag', onMag)
: http://www.espruino.com/Reference#l_Object_removeListenerNote that if you do:
It won't work though, because
onMag
is basically a different function each time.Or you can just do
Puck.removeAllListeners('mag')
: http://www.espruino.com/Reference#l_Object_removeAllListenersBut personally if you can I'd just make sure you only call
Puck.on('mag',
once - there's no need to call it at startup each time because Espruino will remember.