I've just added Function.prototype.bind, so you should now (it the latest builds) be able to do:
Function.prototype.bind
function EasyVR(ser,onCm,onTo) { this.ser = ser; this.onCommand=onCm; this.onTimeout=onTo; this.ser.on('data',evr.onWatch.bind(this)); // <-------------- this.vrstate=-1; this.stsr='o'; this.rcvv=""; } ; EasyVR.prototype.onWatch=function(data) { console.log(this); };
I'm not sure which is better - the bind will actually be slightly faster though.
bind
@Gordon started
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.
I've just added
Function.prototype.bind
, so you should now (it the latest builds) be able to do:I'm not sure which is better - the
bind
will actually be slightly faster though.