Last active
September 9, 2015 14:49
-
-
Save heri/8c6177ca9b2b15820b00 to your computer and use it in GitHub Desktop.
This file contains 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
# 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