Re: [whatwg/dom] Removing event listeners through an identifier (#208)

Could `addEventListener` work similar to how `setTimeout` and `clearTimeout` works? For example, with `setTimeout`, `setInterval`, `requestAnimationFrame`, it's easier for apps to keep track of an `id` rather than a function which needs be called later on. For example:

```
var id = obj.addEventListener('click', ...);
document.clearEventListener(id);
```

Using a id rather than holding onto references to the handler could also reduce the potential for memory leaks.

What would be great is if the returned `id` could be global and not specific to the object the handler was added to. I used `document.clearEventListener` just for an example. Additionally, whatever removes the listener could accept one id, or an array of ids.


---
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-208922072

Received on Tuesday, 12 April 2016 14:02:38 UTC