W3C home > Mailing lists > Public > public-webrtc@w3.org > October 2012

Re: Event handlers in RTCPeerConnection

From: Adam Bergkvist <adam.bergkvist@ericsson.com>
Date: Mon, 1 Oct 2012 16:42:21 +0200
Message-ID: <5069ABCD.8000701@ericsson.com>
To: Martin Thomson <martin.thomson@gmail.com>
CC: Randell Jesup <randell-ietf@jesup.org>, "public-webrtc@w3.org" <public-webrtc@w3.org>
On 2012-09-28 19:47, Martin Thomson wrote:
> On 28 September 2012 01:58, Adam Bergkvist <adam.bergkvist@ericsson.com> 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.

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

This archive was generated by hypermail 2.3.1 : Monday, 23 October 2017 15:19:30 UTC