- From: Jake Archibald <notifications@github.com>
- Date: Mon, 14 Jun 2021 08:25:41 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Monday, 14 June 2021 15:26:19 UTC
Example using abort controllers: ```js const controller = new AbortController(); const { signal } = controller; someElement.addEventListener('keypress', (event) => { if (event.key !== 'Escape') return; controller.abort(); // Process the event }, { signal }); ``` I don't think any of the proposed shorthands help here. I agree that `once` isn't particularly useful. `eventFilter` is interesting and makes it a bit more useful, but it doesn't help the case where you're waiting for one of multiple events: ```js const controller = new AbortController(); const { signal } = controller; thing.addEventListener('load', (event) => { controller.abort(); // … }, { signal }); thing.addEventListener('error', (event) => { controller.abort(); // … }, { signal }); ``` -- 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/990#issuecomment-860774998
Received on Monday, 14 June 2021 15:26:19 UTC