Re: [w3c/webcomponents] Scoped Custom Element Registries (#716)

@hayatoito Just an idea, for example, I think `CustomEventRegistry` can be an EventTarget. 

```
const xRegistry = new CustomElementRegistry();

class XFoo extends HTMLElement {
  constructor() {
    super();
    this.addEventListener('click', () => {
      // dispatch a scoped event
      xRegistry.dispatchEvent(new CustomEvent('xEvent'))
    });
  }
}
class XBar extends HTMLElement {
  constructor() {
    super();
    // subscribe scoped events
    xRegistry.addEventListener('xEvent', () => {
      // ...
    });
  }
}

xRegistry.define('x-foo', XFoo);
xRegistry.define('x-bar', XBar);
```

![image](https://user-images.githubusercontent.com/1529180/39163686-81288732-47b6-11e8-8c94-2088d0449515.png)


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/716#issuecomment-383787698

Received on Tuesday, 24 April 2018 02:59:12 UTC