addEventListener with side effects

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 UTC