You are reading a single comment by @DrAzzy and its replies. Click here to read the full conversation.
  • How do I make this work here?

    
    function EasyVR(ser,onCm,onTo) {
      this.ser = ser;
      this.onCommand=onCm;
      this.onTimeout=onTo;
      this.ser.on('data',this.onWatch);
      this.vrstate=-1;
      this.stsr='o';
      this.rcvv="";
    } ;
    
    EasyVR.prototype.onWatch=function(data) {
    	console.log(this);
    };
    
    

    This seems to be set to... an object containing everything. How do I get it to be the object that the function is a property of?

    Secondly - with same code, try doing:

    evr.onWatch=function(){console.log("roarĀ­!!!");} //where evr is an instance of that object

    then provoke another serial data event. The callback isn't updated. How can I make it call the function I pointed it at, instead of remembering what said function happened to be when I initially set up the callback? Is this behavior intended?

    Thanks

About

Avatar for DrAzzy @DrAzzy started