Hm.. For whatever reason, it works now.. I'm a bit embarrassed.. Just for reference, code is here:
function aClass() {};
aClass.prototype.testEmit = function() {
setTimeout(()=>this.emit('TestEvent'), 1000);
}
var a = new aClass();
a.on('TestEvent', ()=>console.log('Got event'));
a.testEmit(); // get 'Got event' printed in log
var a1 = new aClass();
a1.testEmit(); // event here is not caught
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.
Hm.. For whatever reason, it works now.. I'm a bit embarrassed.. Just for reference, code is here: