W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2015

Re: Callback when an event handler has been added to a custom element

From: Mitar <mmitar@gmail.com>
Date: Sat, 7 Nov 2015 01:01:37 -0800
Message-ID: <CAKLmikNFpd-fPxribPVnwrqh6iJs39kiGU59aU+j_FMSyatcWQ@mail.gmail.com>
To: Domenic Denicola <d@domenic.me>
Cc: public-webapps <public-webapps@w3.org>

On Fri, Nov 6, 2015 at 5:12 PM, Domenic Denicola <d@domenic.me> wrote:
> In general I would be cautious about this kind of API. Events are not expected to have side effects, and adding listeners should not cause an (observable) action.

Hm, but message port API itself has such a side-effect:


"The key difference is that when using addEventListener(), the start()
method must also be invoked. When using onmessage, the call to start()
is implied."

So we already have an example of an interface where "start()" is
called automatically.

So how can I do something like that on the custom element as well?

> A better design in your case would probably be to have a specific method on the custom element which "starts" it (and thus starts its associated message port).

For me this feels like leaking internal implementation details to the outside.


Received on Saturday, 7 November 2015 09:02:05 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:14:58 UTC