Skip to content

Instantly share code, notes, and snippets.

@jimeh
Last active December 15, 2015 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimeh/5317406 to your computer and use it in GitHub Desktop.
Save jimeh/5317406 to your computer and use it in GitHub Desktop.
Ice Coffee Script vs Promises/A (as I've understood it at least)
search = (keyword, callback) ->
host = "http://search.twitter.com/"
url = "#{host}/search.json?q=#{keyword}&callback=?"
await $.getJSON(url, defer(json))
callback json.results
search "hello world", (results) -> console.log(results)
search = (keyword) ->
host = "http://search.twitter.com/"
url = "#{host}/search.json?q=#{keyword}&callback=?"
$.getJSON(url) # returns a promise
promise = search("hello world")
promise.then (results) -> console.log(results)
@reduxdj
Copy link

reduxdj commented Aug 30, 2013

I prefer the straight ahead promise approach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment