From: Mitar [mailto:mmi...@gmail.com] 

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

I think that is just a very bad API. The platform is unfortunately full of bad 
APIs :). In particular, a difference between two different ways of adding event 
listeners is not something authors ever think about.

But regardless, if that's all you want, you could do it easily by declaring 
your custom element class like so:

class MyCustomElement {
  set onmessage(handler) {
    this.addEventListener("message", handler);
    this.start();
  }
  // ...
}

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

I strongly disagree. I would instead say it feels like getting rid of magical 
implicit I/O behavior, in favor of making the code say what it does and do what 
it says.

Reply via email to