- From: Andrea Giammarchi <notifications@github.com>
- Date: Tue, 27 Jun 2017 07:38:59 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Tuesday, 27 June 2017 14:39:31 UTC
> But I'm strongly pro an idiomatic event handling API in the core platform. Me too, but that's also my point. This `group` thing looks more like a hack around `addEventListener`. With today ES features we could have a new `addHandler` method where each key can be a string or a symbol so that you have your group of events represented as such: ```js var group = { click(evt) { evt.preventDefault() }, [Symbol('private')](evt) { this.pressRedButton(); }, ['any' + thing](evt) { console.log(evt.type); } }; el.addHandler(group, { capture: true, once: true, context: myObject }); // how to remove a group ? el.removeHandler(group); ``` This can be easily polyfilled too (via `group.handleEvent.call(context, evt)`) and would require one operation to both add and remove instead of N `add/removeEventListener` calls. It fades out the need to create arrow function and it makes you forget about `obj.method.bind(obj)` Or at least, that's what I'd love to have in a platform based on events. -- 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/208#issuecomment-311379109
Received on Tuesday, 27 June 2017 14:39:31 UTC