Re: [whatwg/dom] once() and on() async utilities for EventTarget (Issue #1038)

Seems correct, although we should realize this discussion has moved fast and hasn't had time for everyone to weigh in.

Also

> Using Promise.race() should handle the race conditions when there are multiple events that can be expected.

might deserve some more thought, per @bathos's comment. His footnote made me wonder about

```js
const messageEvent = await window.toPromise("message", { errorType: "messageerror" });
```

or something?

... also, writing that out, `toPromise()` is now feeling less good as a name, because I forgot that usually `EventTarget`s are actually objects with tons of non-event functionality (like `Window`), so it feels funny to say `window.toPromise()` as if we're converting the window itself into a promise :(.  Same for `toAsyncIterator()`. Sigh, more bikeshedding needed...

- `window.eventAsync("message")` / `window.eventsAsync("message")` ?
- `window.eventPromise("message")` / `window.eventIterator("message")` ?

-- 
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/1038#issuecomment-985757593

Received on Friday, 3 December 2021 19:03:09 UTC