Re: Event handlers in RTCPeerConnection

On 2012-09-28 19:47, Martin Thomson wrote:
> On 28 September 2012 01:58, Adam Bergkvist <> wrote:
>> Each of the "onsomething" attributes needs to be generic EventHandler
>> attributes. To set such an event handler attribute is just one way to
>> register a listener for an event.
> Not "needs to be", just "can be".

True, but it's (as you state below) a convention to handle all events in 
a general way. E.g., it should be possible to register a listener for 
any event with EventTarget.addEventListener() which takes a general 
EventListener as its second argument.

> EventHandler is just the default for a callback of the form:
>     [TreatNonCallableAsNull]
>     callback EventHandlerNonNull = any (Event event);
>     typedef EventHandlerNonNull? EventHandler;
> As opposed to Function, which is probably something like:
>     callback Function = any (any... arguments);
> This implies that if you wish to declare an onsomething event handler
> that consumes an event with additional parameters you would have:
>     interface MyInterface : EventTarget {
>        attribute MyEventHandler? onsomething;
>     };
>     [TreatNonCallableAsNull]
>     callback MyEventHandler = void (MyEvent e);
>     interface MyEvent : Event {
>        readonly attribute any myProperty;
>     };
> There is no ambiguity there.  One advantage is that it links a to b to c.

But it will introduce a redundant specialized event handler type, since 
the additional parameters are a part of the event and not the callback 
argument list.

> That said, there is a convention that has developed whereby this
> linkage is performed in prose.  If that is the choice of the editors,
> can I request that the linkage be added?

The "onsomething" attribute event handlers currently state which event 
type they handle. The type name links to the table in section 15 that 
summarizes the event type to interface mappings.

If you think that it's insufficient, please give an example on how you 
think it can be clarified.

Have in mind that we have some newly added event interfaces (e.g. 
RTCIdentityEvent) that are not fully documented yet.


Received on Monday, 1 October 2012 14:42:49 UTC