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

That's an interesting example, I guess the counter-example is:

```js
for await (const e of textInput.on('input')) {
  getData(textInput.value).then((data) => {
    render(data);
  });
}
```

To prevent the blocking behavior you were mentioning there, but regardless the main crux here is that returning an async iterator may guide people to using structures like for await... of that isn't what they probably intend, and if they want to use an async iterator differently they'll need to code around that in ways that aren't incredibly common.

Like say you wanted debouncing or to collect a series of touch events together, that's more intuitive with an Observable. So before we commit to an async iterator for `on()` we should probably figure out what's happening with the Observable proposal.

`once()` seems less controversial though?

And if I've opened the door to the bikeshed, I've often used "when" for things Promise factories that are not Promises themselves, because it looks nice next to "then". (**when()** this event fires, **then()** take this action).

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/1038#issuecomment-1215925985
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/issues/1038/1215925985@github.com>

Received on Monday, 15 August 2022 22:24:34 UTC