W3C home > Mailing lists > Public > public-audio@w3.org > October to December 2012

[Bug 20502] MIDIEvent should have a port attribute

From: <bugzilla@jessica.w3.org>
Date: Tue, 25 Dec 2012 21:24:00 +0000
To: public-audio@w3.org
Message-ID: <bug-20502-5429-qPhOanQ3CW@http.www.w3.org/Bugs/Public/>
https://www.w3.org/Bugs/Public/show_bug.cgi?id=20502

--- Comment #5 from Marcos Caceres <w3c@marcosc.com> ---
(In reply to comment #4)
> (In reply to comment #3)
> > (In reply to comment #2)
> > > Can't you easily set this up by binding the onmessage handler?
> > 
> > It's probably not a good idea to use the onmessage handler because it can be
> > overridden by anyone (please also see issue at bottom of this reply). 
> 
> "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? 

> >Also,
> > to set that up requires some minor gymnastics when you could just get it for
> > free from the event itself.
> 
> Well, it's not totally "free" - because it would have to be set on the event
> object for each call then - but not very expensive, I suppose.
> 
> > Like: 
> > var recording = []; 
> > for(....; i++){
> > midiaccess.getInputs()[i].addEventListener('message', function (e) {
> >   var instrument = {port: this, event: e};  
> >   recording.push(instrument);
> >   //or 
> >   e.port = this; 
> >   recording.push(e);
> > }); 
> > 
> > The second case above kinda sucks because it's not nice to add things to
> > object that you don't own (in this case a MIDIEvent). 
> 
> Well, but this leads me to believe it's not a good idea, because it will
> encourage the use of adding things to the MIDIPort (to get back to your own
> code), and binding (in the rare case that you would need a pointer back to
> your objects that isn't just a function pointer).

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'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.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
Received on Tuesday, 25 December 2012 21:24:01 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:50:04 UTC