Created
August 4, 2011 05:54
-
-
Save fennb/1124580 to your computer and use it in GitHub Desktop.
Asynchronous loop issues illustrative example
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
// Illustrative case | |
for (var i = 0; i < recentBlogPostIds.length; i++) { | |
var blogPostId = recentBlogPostIds[i]; | |
var results = []; | |
// Fetch from DB | |
asynchronousDB.getBlogPostById(blogPostId, function(err, post) { | |
htmlFragment = templating.render(post); | |
results.push(htmlFragment); | |
}); | |
} | |
// Return results | |
return results; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment