public
Last active

IcedCoffeeScript examples

  • Download Gist
gistfile1.coffee
CoffeeScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# 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()

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.