Re: [whatwg/dom] [Proposal] Add EventTarget.getEventListeners() (#412)

I like the idea of namespacing events; this way, I can remove all my handlers later on without needing to keep their references (which is very helpful when binding functions). As far as I understand, when using a Symbol as a namespace one could create a private namespace which could not be intercepted by third parties (which might be important for developers of third-party code).

E.g.:

```
(() => {
  const namespace = new Symbol('eventNamespace');

  function myFn() {}

  function add() {
    document.addEventListener('click', myFn, { namespace });
  }

  function remove() {
    document.removeEventListener('click', null, { namespace });
  }
});
```

Combined with lhjarbs idea of a `copyListeners` API, this should probably cover most of the use-cases?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/412#issuecomment-280700993

Received on Friday, 17 February 2017 16:42:08 UTC