-
Notifications
You must be signed in to change notification settings - Fork 1
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
Motivation #3
Comments
Dump from #5 (comment): There are specific rare use cases for performance, interoperability, and even debugging that would be helped by synchronous inspection. They are rare and intended only to be used by library authors. For example, if you are writing a templating library (or perhaps a "model" library as part of a MVC trio), you may wish to support promises as attributes of your template data. In many cases, the promises will already be fulfilled or rejected by the time you want to render things to the DOM. If so, it's much better to insert the data at the same time as the initial render, than to re-render once for each time a template attribute becomes fulfilled or rejected, or to find the location of the metamorphs you inserted and update each of them. As another example, certain convenience methods, like Finally, certain utility methods, like |
In an ideal world this would not be true. Even without synchronous inspection, multiple calls to |
Consider the case where you accept a promise for an array as well as an array of promises. That pushes your solution into an extra turn. |
@ForbesLindesay it does not, if calls to nextTick within a nextTick callback still add to the current turn's queue (which is the case in Node.js >= 0.9). |
What's the status of this idea? Seems like there was general consensus that it was useful but I can't see any mention of it in the spec. |
I've left the motivation sections as TODOs.
I think the templating use case, as explained by @ForbesLindesay here, is a good one.
I also think that assimilation could benefit. Currently, you can only assimilate by waiting a turn. Thus, there are usually at least two turns in consuming an assimilated promise:
foreignPromise.then(deferred.resolve, deferred.reject)
andnativePromise.then(...)
. With synchronous inspection available, the first step could be made synchronous while not losing the guaranteed asynchronicity of the second.The text was updated successfully, but these errors were encountered: