-
-
Save z-lite/de88fd56fa59cb7e1f4b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Examples from http://andreypopp.com/posts/2012-10-30-callbacks-to-promises.html | |
# using IcedCoffeeScript http://maxtaco.github.com/coffee-script/ : | |
search = (engine, q, cb) -> | |
$.ajax(url: engine, success: cb) | |
await | |
search 'google', 'js', defer(googleSearched) | |
search 'bing', 'js', defer(bingSearched) | |
processResults(bingSearched, googleSearched) | |
await | |
$.ajax url: 'google', success: defer(googleSearched) | |
$.ajax url: 'bing', success: defer(bingSearched) | |
processResults(bingSearched, googleSearched) | |
await | |
$('.left').fadeIn 500, defer() | |
$('.right').fadeOut 500, defer() | |
# animations are done, do something else | |
timeoutSet = (timeout, next) -> setTimeout next, timeout | |
await timeoutSet 500, defer() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment