[Bug 20502] MIDIEvent should have a port attribute

https://www.w3.org/Bugs/Public/show_bug.cgi?id=20502

--- Comment #7 from Marcos Caceres <w3c@marcosc.com> ---
(In reply to comment #6)
> (In reply to comment #5)
> > > "Can't you easily set this up by binding the message handler (onmessage or
> > > addEventHandler function)?"  Binding is on the function object, irrelevant
> > > of onmessage or addEventHandler.
> > 
> > Maybe I'm not getting what you mean here. Are you literally saying use
> > .bind()? Or something else? 
> 
> Yes, calling .bind.
> 
> port.addEventListener( "message", myhandler.bind( myobj ) );

I honestly don't know how many people use or understand bind (I'm personally
often confused by it). I've personally have never have had to use it. That's
not to say that people don't use bind.

> > Oh, my example was supposed to be all bad - I'll see if I can come up with a
> > real usage scenario as I just made that on up on the spot. In any case, I
> > think we might be misunderstanding each other, but I can understand the need
> > for a good justification to adding this. 
> > 
> > I might need a stronger use case. At the moment, this might just fall into
> > the "nice to have" category. 
> 
> I'm not fundamentally opposed, just want to ensure we have strong
> justification.

Agree. Would be good to hear if Jussi or others have a strong use case. 

> > I'll also be honest: I didn't know that "this" would become the port itself
> > before Jussi mentioned it. It makes sense, but I wonder if many developers
> > know about that.
> 
> Hmm, noted.  Have to fix that in my shim, I think.

I added it the other day to my fork by doing something like:

function MIDIPort(...){
  var self = this;
  ... 
  function (type, listener, useCapture) {
     dispatcher.addEventListener(type, function (e) {
        listener.call(self, e);
     }, useCapture);
  }
}

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Tuesday, 25 December 2012 23:11:05 UTC