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

Re: addEventListener and side-effects

From: Anne van Kesteren <annevk@opera.com>
Date: Tue, 06 Sep 2011 17:24:31 +0200
To: "James Graham" <jgraham@opera.com>, "Robin Berjon" <robin@berjon.com>
Cc: www-dom@w3.org, public-device-apis@w3.org
Message-ID: <op.v1d7q5up64w2qv@g239.guest-int.opera.com>
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
Received on Tuesday, 6 September 2011 15:25:04 UTC

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