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

Add support for ES6 Generator Functions in release 5.0 #2506

Closed
kenrick opened this issue Jan 19, 2015 · 12 comments
Closed

Add support for ES6 Generator Functions in release 5.0 #2506

kenrick opened this issue Jan 19, 2015 · 12 comments

Comments

@kenrick
Copy link

kenrick commented Jan 19, 2015

Hey Everyone,
Over the week I forked express and added generator function support for middleware and request handlers. It was only a few lines of code, here is the commit, and I recorded my results in this blog post.

Would it be possible to add support in the next release of Express.

@dougwilson
Copy link
Contributor

As long as it works in Node.js 0.10 out of the box, then certainly possible.

@dougwilson
Copy link
Contributor

Looking at your commit, though, clearly Express 4 already supports generators: just pass the result of co.wrap to Express.

@Fishrock123
Copy link
Contributor

I think using wrap-fn would be a better implementation. Also supports promises and sync functions.

@Fishrock123
Copy link
Contributor

Also +1 to @dougwilson's observation.

@dougwilson
Copy link
Contributor

I do want to eventually natively support Promises in Express handlers, which really supersedes this; co was only meant to be a stop-gap to abuse generators and provide a trampoline. I hear JS is closer to getting the await keyword, which works with Promises and makes co obsolete.

@kenrick
Copy link
Author

kenrick commented Jan 20, 2015

That is correct @dougwilson, using co was just for a POC. I'm glad to hear that might be Promises would be natively supported at some point.

What I would really want is to see support for async/await to be added to roadmap.

@dougwilson
Copy link
Contributor

What I would really want is to see support for async/await to be added to roadmap.

That is promise support. As soon as we support Promises you would have await for free. So it's basically on the roadmap.

@kenrick
Copy link
Author

kenrick commented Jan 20, 2015

Awesome thanks @dougwilson

@ryhinchey
Copy link

Initial promise support landed in Express.js 5.0.0-alpha.7

#2259 (comment)

I think this issue can be closed

@wesleytodd
Copy link
Member

I agree we should close this. We have promise support being worked on, and if we ever want to pick up more advanced usage of generator functions in the future we can open a new issue with a more detailed proposal.

@dougwilson
Copy link
Contributor

Yea, this is an old one. The generator stuff was a stand in before async keyword (based on promises) anyway, so I don't think it's even relevant in the general sense any more.

@kenrick
Copy link
Author

kenrick commented Feb 20, 2020

Yes, this is no longer an issue. Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants