Re: addEventListener and side-effects

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