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


On Fri, Nov 6, 2015 at 5:12 PM, Domenic Denicola <> 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