cujojs / most

Ultra-high performance reactive programming
MIT License
3.49k stars 231 forks source link

Claiming support for "asynchronous generators" creates confusion #538

Open getify opened 4 years ago

getify commented 4 years ago

The documentation has a section called "Asynchronous Generators", which I found while searching for native JS "stream" support. I was dismayed to see that this term is being used by Most in a way that's incompatible with how native JS behaves.

I found old issues (from 2017) about the topic of "async iteration" support (aka, JS's "asynchronous generators"), but didn't find anything since (sorry if I missed it).

The support for "generators that yield promises" is not the same thing as an "asynchronous generator", since the key difference is whether the .next() call on an iterator (attached to such a generator) returns Promise<IteratorResult> or whether it returns IteratorResult<Promise>.

The latter is what Most seems to support, but JS's asynchronous generators are the former interpretation.

I would suggest the documentation be updated to clarify, preferably by changing from "Asynchronous Generators" to "Promise-Producing Generators" or something like that. It'd be great if that section also noted this difference, to reduce future confusion.

Additionally, it'd be nice if Most re-visited the 2017 suggestion to roll actual JS async-generators support in. Back then it was a stage 3 proposal, but today it's been stable in JS for 2 years and has become the foundation of how all native DOM streams work. It'd be great to have Most support those directly, out of the box.