Created
February 16, 2011 15:50
-
-
Save ncb000gt/829593 to your computer and use it in GitHub Desktop.
Async dep example with Cradle.
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
var data = [1,2,3,4,5,6,7,8,9,10], | |
len = data.length, | |
count = 0; | |
function f() { | |
//do your dependent stuff here | |
} | |
data.forEach(function(i) { | |
db.save(key, {val: i}, function(err, res) { | |
//data for i saved yay! | |
count++; | |
if (count === len) { | |
f(); | |
} | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment