W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2011

Re: addEventListener and side-effects

From: Robin Berjon <robin@berjon.com>
Date: Tue, 6 Sep 2011 16:10:19 +0200
Cc: www-dom@w3.org, public-device-apis@w3.org
Message-Id: <CFD51365-57F8-4955-80D3-5C30ACB9C380@berjon.com>
To: James Graham <jgraham@opera.com>
On Sep 6, 2011, at 14:59 , James Graham wrote:
> On Tue, 6 Sep 2011, Robin Berjon wrote:
>> as most of you are probably aware, there have been recent threads on both the Geo list[0] and the DAP list[1][2] about calls to addEventListener producing side-effects (or purported side-effects).
> I am very much against addEventListener having side effects. Where we have nice simple invariants in the platform it is good to keep them.

Right, but part of the question is whether triggering an event upon registration is indeed a side-effect. Presumably, there is necessarily an effect of event registration (certainly for this type of event), which causes some code to be initialised with a specific intent (dispatching events to a given window about orientation sensors or the level of a battery). It's very much unclear to me what is possibly wrong with such a piece of code deciding that when it gets initialised, it dispatches an event. That's probably the point that I'm missing.

Robin Berjon - http://berjon.com/ - @robinberjon
Received on Tuesday, 6 September 2011 14:11:04 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:18 UTC