Last active
March 8, 2017 05:02
-
-
Save toddzebert/fc2b3f4b69dadda2f9d87698e63c4483 to your computer and use it in GitHub Desktop.
Nested Async Callback example w/"all" & "race" patterns - check the console log
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
// requires https://gist.github.com/toddzebert/d41f06a7a33f5ada1557637a89278531 | |
// requires https://gist.github.com/toddzebert/5958be630e81bb9ba16fb6931c339c88 | |
var posts = [], data = { id: 4 }; | |
getAuth(data, function (res) { | |
data.auth = res; | |
getProfile(data, function (res) { | |
data.profile = res; | |
getFeed(data, function (res) { | |
data.feed = res; | |
var getPosts = data.feed.map(post => getPost(post)); | |
all(getPosts, function(res) { | |
data.posts = posts; | |
race([getAd(), getAd(), getAd()], function(res) { | |
data.ad = res; | |
console.log(data); | |
}); | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment