-
Notifications
You must be signed in to change notification settings - Fork 479
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 deep resolution of Thenables in context #590
Conversation
9a0085e
to
2089482
Compare
Previously tests that called dust.render and had an async component (like chunk.map) would always pass. * Upgrade jasmine to 2.0.1 and refactor unit tests for compatibility * Upgrade Rhino JAR from 1.7R5-rc to 1.7R5-final
5cbbc68
to
9198126
Compare
Reworked the PR into two separate commits so it was easy to see the changes needed to support deep resolution. |
The async commit is awesome. Thanks for that. The deep promise resolution hurts my brains. Please add a test in case one of the thenable thens (I N C E P T I O N) fails. As discussed a partial function here would make this easier to grok. The closure to get at Nice to have but not necessary |
If you have a Thenable `{foo}` that resolves with `{"bar": "baz"}`, you can now put `{foo.bar}` in a template and get "baz".
Added a third commit with an explicit closure creation. Let me know if you like that better. I think I don't like it as well just because it's one extra layer of indirection for me to keep track of in my mental model. I can see how it makes it more explicit, though. |
Added some new tests, by the way. How sick is this:
Half of the section key lookup is a promise and the other half isn't. |
Thinking of the possibility for a defer helper or just returning promises
from helpers
|
That's what At Amazon we had a wrapper around
|
You can definitely return a promise from a helper now, that's maybe 60% the point of this PR and the one before it, so that people can plop
vs
|
Add deep resolution of Thenables in context
As part of this change, Jasmine has been updated to properly handle async render tests. Before this, any asynchronous test that called dust.render() always passed.
Closes #588