Re:Await and Defer in Coffeescript core
by arocks on Sunday December 18, 2011 @08:01AM
(#3366556)
For those who didn't understand the new constructs, the following excerpt from TameJS[1] website helps:
> `await` marks a section of code that depends on externals events, like network or disk activity, or a timer. An `await` block contains one or more calls to `defer`. Calling `defer` constructs a new deferral. Only once all deferrals inside an await block are fulfilled does control continue past it. `defer()` behaves much like a normal function; it returns an anonymous function that you give to your async functions. These functions "fulfill" their deferrals by calling the callbacks passed to them.
> `await` marks a section of code that depends on externals events, like network or disk activity, or a timer. An `await` block contains one or more calls to `defer`. Calling `defer` constructs a new deferral. Only once all deferrals inside an await block are fulfilled does control continue past it. `defer()` behaves much like a normal function; it returns an anonymous function that you give to your async functions. These functions "fulfill" their deferrals by calling the callbacks passed to them.
[1]: http://tamejs.org/