Skip to content

Instantly share code, notes, and snippets.

@toddzebert
Last active March 8, 2017 05:02
Show Gist options
  • Save toddzebert/fc2b3f4b69dadda2f9d87698e63c4483 to your computer and use it in GitHub Desktop.
Save toddzebert/fc2b3f4b69dadda2f9d87698e63c4483 to your computer and use it in GitHub Desktop.
Nested Async Callback example w/"all" & "race" patterns - check the console log
// 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