-
Notifications
You must be signed in to change notification settings - Fork 15
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
ES2016 meta property suggestion: function.promise
to access an asynchronous function's implicit promise
#4
Comments
Can we make this more generic if https://github.com/jhusain/compositional-functions happens it might not be a promise |
I could imagine something similar for Generators and AsyncGenerators like |
I'm not sure about generalizing those. I liked the idea at first, but there are a few problems. First, "context" is an overloaded word: when JavaScript developers hear the word "context", some think about the running execution context's LexicalEnvironment, others think about the running execution context's LexicalEnvironment's EnvironmentRecord's I believe more explicit terms such as edit: grammar |
And the other problem is that you will hardly find a word that is generic enough to cover all the suggested use cases and that still holds any meaning. Perhaps |
Yeah you're right, and actually thinking about it an Async Iterator has both an implicit promise (which is constantly changing) and an iterator. |
When working with async functions (through Babel), I sometimes face use cases where it would be desirable to get a reference to the currently running async function's promise (e.g. to store the reference in a lexical binding).
Currently, it looks like I have to split the async function in two functions in order to store the return value (a reference to the promise) of an async function, which often results in ugly code.
Hence, I propose a new
function.promise
meta property which resolves to the currently running async function's underlying promise. I'd like to know whether this sounds feasible before working out the details of the proposal.@lukehoban @allenwb WDYT?
The text was updated successfully, but these errors were encountered: