-
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
Thenable support #569
Thenable support #569
Conversation
Before:
After:
|
Open questions: [x] Currently a rejected promise calls |
chunk.end(data); | ||
} | ||
}, function(err) { | ||
chunk.setError(err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the {:error}
idea. Let's make sure this gets into the documentation before/as this feature gets released.
d6cfccf
to
92f3750
Compare
#573 includes docs for this |
}, | ||
{ | ||
name: "thenable reference", | ||
source: "Eventually {magic}!", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what would happen if someone tries to reference magic.foo
. I remember we had some logic that would fire the magic function and look for foo in it's return value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A Thenable is not a function so it would look for a property on the Object called foo
Dust handles thenables (promises) in context, either directly or as the return value of a context helper. Dust will reserve a chunk asynchronously for the eventual return value of the promise. If the promise is invoked as a reference, the reference will become the eventual return value. If the promise is invoked as a section, the eventual return value will be pushed onto the stack.
Dust handles thenables (promises) in context, either directly or as the return value of a context helper. Dust will reserve a chunk asynchronously for the eventual return value of the promise.
If the promise is invoked as a reference, the reference will become the eventual return value. If the promise is invoked as a section, the eventual return value will be pushed onto the stack.
This allows Dust to integrate with third-party modules that don't know what Dust is, while still allowing those modules to make use of Dust's asynchronous nature seamlessly.
Closes #568