You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • I've just added Function.prototype.bind, so you should now (it the latest builds) be able to do:

    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.

About

Avatar for Gordon @Gordon started