Skip to content
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

ES2017 async functions #2079

Closed
wants to merge 1 commit into from
Closed

ES2017 async functions #2079

wants to merge 1 commit into from

Conversation

thsmi
Copy link

@thsmi thsmi commented Jan 2, 2018

ES2017 standardized the async statement, which makes dealing with promises less painful.

ES2017 standardized the async statement, which makes dealing with promises way less painfull.

ES2017 standardized [async functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function). Such function returns by definition always a promise. The javascript engine wraps an async function into a promise and enures that such a promise will be automatically resolved when the async function returns or it will be rejected upon any uncaught exception.

This makes the explicit done() call required by gulp 4 obsolete and avoids the "Did you forget to signal async completion?" error message. Further more it allows you to write asynchonous code in a synchonous style by using the await statement.
Copy link
Member

@demurgos demurgos Jan 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, it's a good idea to mention async functions.

Gulp (both 3 and 4) support tasks returning Promises. Using async functions is more a replacement to returning a Promise than using a done callback. I'd just reword this paragraph to say that it provides a lighter syntax over Promises.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we handle all sorts of async completion (streams, child process, promises, event emitters, observables & callbacks) so I don't want to make it sound like you can't just return a promise.

@phated
Copy link
Member

phated commented Jan 18, 2018

I'd love to get this fixed and merged. I recently showed off using async functions with gulp 4 and everyone loved it.

@phated
Copy link
Member

phated commented Jan 23, 2018

I'm thinking about making this a recipe or moving into a separate "async completion" markdown file.

@phated
Copy link
Member

phated commented Jul 29, 2018

Now that #2182 is merged, we're documenting this pattern so I'm going to close this. Thanks for the recommendation @thsmi!

@phated phated closed this Jul 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants