This repository was archived by the owner on Jun 10, 2018. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First, notes from the discussion on the CoffeeScript mailing list, taken from discussion earlier today on IRC.
I've decided to make async a compiler option. If the option is all, all helper blocks are called asynchronously. If it is off, the function is identical to the current Eco generated functions. This is because the helper author and the compiler invoker are almost certainly the same person, and they will know if async is necessary or not.
When async is on, the generated function takes a callback. If it is off, the generated function returns its result as it always has.
This leads to the following programming problems with async Eco:
I've come to the following decisions regarding the questions at the end of that post:
Maybe there's a way for the helper to say that it is async, instead of having to remember that in the code? (Too much complexity defeats the use case.) ~ Currently, I'm tucking an exclamation point into the directive to indicate that the call should be async. This is fiddly. The async implementation is supposed to be transparent to the template author. When I'm writing templates, I don't want to think about concurrency. The use case given for async Eco is a template system for people used to writing themes with a a template language. Telling them they forgot the
!
will only lead to a painful attempt to explain to them what it is for. Thus, I've decided that there will be no extensions to the Eco directives.This decision addresses the other question as well.
Async blocks in code and no callback? You get "[ Function ]" in your blocks. Could easily detect this condition, but how to report the error? Exception? Or let it slide? ~ Instead of async being a property that is applied per block helper, it is applied to all helper blocks in a template using a complier option. This means that if the option is not present, there is no effect at all on the existing Eco templates. This means that if you generate an async method, the async method can assert that it got a callback.