Skip to content

Instantly share code, notes, and snippets.

@heri
Last active September 9, 2015 14:49
Show Gist options
  • Save heri/8c6177ca9b2b15820b00 to your computer and use it in GitHub Desktop.
Save heri/8c6177ca9b2b15820b00 to your computer and use it in GitHub Desktop.
# Callback hell :/
Yelp.get("restaurants").then do |response|
PlacesTasks.sort(response.json[:places]}) do |response|
Place.review(response, {ranking: -1}) do |response|
puts "All finished"
end
end
end
# More readable asynchronous calls with Promises
Yelp.get("restaurants").then do |response|
PlacesTasks.sort(response.json[:places]})
end.then do |response|
Place.review(response, {ranking: -1})
end.then do
puts "All finished"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment