Re: addEventListener and side-effects

On Tue, 06 Sep 2011 16:10:19 +0200, Robin Berjon <robin@berjon.com> wrote:
> 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),

Why would there be an effect? That is not at all the conceptual model.


> 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).

That is the whole thing we are arguing against. Events are dispatched.  
They can be listened for using event listeners. They should not be  
dispatched when adding event listeners.


> 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.

There is no event initialization happening when you register a listener.


-- 
Anne van Kesteren
http://annevankesteren.nl/

Received on Tuesday, 6 September 2011 15:25:04 UTC