Re: PROPOSAL: Use events instead of callbacks

On 03/07/2012 01:44 PM, Rich Tibbett wrote:
> Harald Alvestrand wrote:
>> Q1: Could someone point me at a good description of how events work, and
>> where their definition lives?
>
> http://www.w3.org/TR/dom/#events
>
>>
>> Q2: This style would create an object that represents "the head of the
>> MediaStream". Would it be logical to move some of the manipulation
>> functions we've been thinking of for MediaStreams onto that object, if
>> this is adopted?
>
> You probably want such functions on the MediaStream object directly.
> Assuming you're obtaining secondary use of a MediaStream object (i.e.
> you didn't obtain the MediaStream via your own EventListener) then you
> can still apply these methods to that secondary object directly.
>

I agree. And if some functionality only applies to streams that have 
been acquired via getUserMedia() we have the LocalMediaStream interface 
for that.

>>> I understand that there are some general concerns with this design due
>>> to early existing implementations of the callback approach.
>>> Specifically, Rich and someone from Google should reply with their
>>> thoughts.
>
> Right. We released navigator.getUserMedia in Opera Mobile 12 in to the
> hands of multi-millions of users so this is not a trivial argument at all.
>

Are you planning to use a vendor prefix for PeerConnection and friends?

>>>> examples include XHR and IndexedDB. Events are more flexible than
>>>> callbacks
>>>> as they allow multiple listeners, chaining, and bubbling; none of
>>>> which are
>>>> supported by a single callback (as currently specified in the
>>>> specification). Some applications will not need the flexibility
>>>> provided by
>>>> Events, but it is trivial to emulate a single callback system built
>>>> on top
>>>> of events and is also a common idiom for web APIs:
>
> Perhaps you could provide concrete use cases where multiple listeners,
> chaining and bubbling make it essential that we revisit the callbacks vs
> events discussion.
>

I may have missed something here, but to me, bubbling makes sense for 
objects in the DOM tree. Since this is a pure JavaScript object I can't 
see how it would be used.

/Adam

Received on Wednesday, 7 March 2012 14:00:51 UTC