- From: nilssolanki <notifications@github.com>
- Date: Fri, 17 Feb 2017 08:41:33 -0800
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Friday, 17 February 2017 16:42:08 UTC
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