W3C home > Mailing lists > Public > public-device-apis@w3.org > November 2011

addEventListener with side effects

From: Dominique Hazael-Massieux <dom@w3.org>
Date: Wed, 16 Nov 2011 11:32:08 +0100
Message-ID: <1321439528.26049.93.camel@altostratustier>
To: public-device-apis <public-device-apis@w3.org>, Robin Berjon <robin@robineko.com>
Hi,

When we discussed the model for the battery API a few weeks ago, we
stumbled upon an open issue (ISSUE-113 [1]) around having events
triggered upon registration (i.e. when they are added via
addEventListener), which was an issue the Geolocation WG was working on
for their DeviceOrientation spec.

They discussed that issue at their F2F during TPAC:
http://www.w3.org/2011/11/01-geolocation-minutes.html#item03

During that discussion, it was argued that a callback pattern would
probably have been a better approach for DeviceOrientation due to the
need of powering hardware and getting first event upon registration —
Robin, maybe something to document in the API cookbook after further
discussion with Geo/Hixie/Anne ?

"Hixie: Conceptually with events, you have this thing firing events all
the time and you just hook into it. Conceptually, the events are always
there, not plugging in and turning things on. "

To work around this potential mis-design, specific wording was added to
the DeviceOrientation spec: "Implementations may fire the event if they
have reason to believe the page does not have sufficiently fresh data"

Dom

1. http://www.w3.org/2009/dap/track/issues/113
Received on Wednesday, 16 November 2011 10:32:33 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 9 May 2012 00:14:24 GMT