-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
Feature/async blaze #409
Feature/async blaze #409
Conversation
I've made some progress here:
|
Actually, we could handle it on a per-variable basis too: {{#letAwait x=foo}}
Resolved value (if any): {{x}}.
{{#if @pending 'x'}}x is still pending{{else}}x has resolved or rejected{{/if}}
{{#if @rejected 'x'}}x has rejected {{@rejected 'x'}}{{else}}x has resolved or is still pending{{/if}}
{{#if @resolved 'x'}}x has resolved {{@resolved 'x'}}{{else}}x has rejected or is still pending{{/if}}
{{/letAwait}} It can handle general states (i.e., multiple variables) too: {{#letAwait x=foo y=bar z=baz}}
Resolved value (if any): {{x}}, {{y}}, {{z}}.
{{#if @pending}}some binding is still pending{{else}}all bindings have resolved or rejected{{/if}}
{{#if @rejected}}some binding has rejected{{else}}all bindings have resolved or are still pending{{/if}}
{{#if @resolved}}some binding has resolved{{else}}all bindings have rejected or are still pending{{/if}}
{{/letAwait}} Of course these |
var dataProps = {}; | ||
args.forEach(function (arg) { | ||
if (arg.length !== 3) { | ||
// not a keyword arg (x=y) | ||
throw new Error("Incorrect form of #let"); | ||
throw new Error("Incorrect form of " + path[0]); |
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.
Can we improve this error message early on? I'd rather have some more characters in the bundle but a clear error message that helps me in debugging when users report them.
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.
Okay my bad I just saw that all these views have these short error messages. We may discuss this separately.
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.
Yeah, all of them do that - I'd keep it as a separate topic.
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 just wanna say, a great & very clean PR in my opinion! Code-Wise & Logic-Wise it all looks internally consistent & nice.
You're setting up a solid foundation here I'd say. Thank you guys!
Content-wise I have some questions, if that's ok... If we remember the idea of building another Template helper / operator
This would lead to the desired result being rendered in the template - but the result wouldn't be returned / passed back through the chain as a result value, would it? Could we access the result of the evaluation? Or would that be a differend / second / separate language construct we'd have to add to spacebars / blaze? Consider expressions like these:
For example when used like with the old / oldschool template helpers package:
https://www.blazejs.org/guide/spacebars.html#Attribute-Helpers which kind of threw us for a loop when we were attempting our first async-implementation-attempt ourselves. So that'd be an important part to check too. Thank you guys again for your effort and initiative! :) |
As I'll be taking over this topic, I created #412 with an updated implementation. @DanielDornhardt I'll address your comments later today or somewhere next week. |
This is a draft PR for people see how is adding async to blaze going.
We have accomplished unwrapping promises in the view.
Below there is a print of the screen + in the PR(will not be in the final version, there is the app that I'm using)
Note that to run it:
cd async-test meteor npm i npm run setup meteor
foo is a result of a promise
#letAwait
to Blaze DSL with simple usage(just unwrap);#letAwait
{{await something}}
or{{await s.foo}}
await
keyword, maybe a #await block for thisI've made PR for release 3.0, but I can change this later. Just let me know :)
Closes #364