-
Notifications
You must be signed in to change notification settings - Fork 22.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add async generator documentation #17529
Conversation
Adds pages for the `AsyncGenerator` and `AsyncGeneratorFunction` standard built-in global objects that had been missing from the “Control abstraction objects” section. Fixes: mdn#2803
Co-authored-by: André Jaenisch <Ryuno-Ki@users.noreply.github.com>
Co-authored-by: André Jaenisch <Ryuno-Ki@users.noreply.github.com>
Co-authored-by: André Jaenisch <Ryuno-Ki@users.noreply.github.com>
…star_/index.html Co-authored-by: Daniel D. Beck <daniel@ddbeck.com>
This reverts commit c331788.
…atorfunction/index.html Co-authored-by: wbamberg <will@bootbonnet.ca>
…atorfunction/index.html Co-authored-by: wbamberg <will@bootbonnet.ca>
A lot of the examples here are directly ported from their sync counterparts and appear overly contrived. Welcoming more examples since I can't think of any async work besides database connection, file system access, and web requests. (Maybe I should make examples with |
I would like to invite @lmammino to have a look as he recently released an iteration protocols workshop on the topic. Hopefully he would be able to spot any glaring transgressions wrt the protocols' documentation. |
files/en-us/web/javascript/reference/global_objects/asyncgenerator/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/javascript/reference/global_objects/asyncgenerator/index.md
Show resolved
Hide resolved
files/en-us/web/javascript/reference/global_objects/asyncgenerator/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/javascript/reference/global_objects/asyncgenerator/next/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/javascript/reference/global_objects/asyncgenerator/next/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/javascript/reference/global_objects/asyncgenerator/next/index.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have one nit. Re-request my review when this is ready to be merged.
files/en-us/web/javascript/reference/global_objects/asyncgenerator/index.md
Show resolved
Hide resolved
I've slightly reworked the examples. I think async generators are not very useful without bringing some external APIs like |
files/en-us/web/javascript/reference/global_objects/asyncgenerator/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/javascript/reference/global_objects/asyncgenerator/next/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/javascript/reference/global_objects/asyncgeneratorfunction/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/javascript/reference/iteration_protocols/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/javascript/reference/global_objects/generator/next/index.md
Outdated
Show resolved
Hide resolved
I suppose a more contrived example that could be made would be converting |
I think the argument about tables vs. lists is well-made and deserves better attention. (It harms maintainability as well.) Shall we start a discussion? |
An object implements the async iterable protocol when it implements the following methods: | ||
|
||
| Property | Value | | ||
| ------------------- | --------------------------------------------------------------------------------------------------------------- | | ||
| `[Symbol.asyncIterator]` | A zero-argument function that returns an object, conforming to the async iterator protocol. | | ||
|
||
An object implements the async iterator protocol when it implements the following methods: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The table wasn't completely removed(?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! iterable vs. iterator, sorry I didn't catch that; not sure if you want to remove that though, even though it is small.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about it—this one seems trivial enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's land this \o/.
If more changes are needed, they can be in follow-ups. No need to hold this for perfection.
Fantastic to see this landed! ❤️ |
Summary
Fix #1459
Fix #2248
Fix #2803
Continuation of #2861. Most credit goes to @DerekNonGeneric.
For now this is still a draft, only submitting because I suck at branch management and I risk accidentally deleting this branch if not published to remote while cleaning all local branches. TODOs:
async function*
statement@@asyncIterator
(First time trying the workflow of using
gh pr checkout
to checkout a fork's branch and then pushing to a different forked remote. Looks like it works?)Motivation
Supporting details
Related issues
Metadata