Unfinished and not tested beyond my own case.
Usage
var wait = new Wait();
wait.complete(function () {
console.log('we are done - now report');
});
$.get(url, wait.until(function (data) {
// do something with data
});
db.users.find(wait.until(function (err, docs) {
// we've found users in the mongo db
}));
Maybe have a look at when.js's
when.all
andwhen.reduce
. They can join multiple tasks, and might do what you need. Here's a quick take on the originalwait
usage with when.js: