Flow Control Library
by sporto
HTML
<script src="//cdnjs.cloudflare.com/ajax/libs/async/0.9.0/async.js"></script>
JavaScript
// setup
function finder(records, cb) {
setTimeout(function () {
records.push(3, 4);
cb(null, records);
}, 500);
}
function processor(records, cb) {
setTimeout(function () {
records.push(5, 6);
cb(null, records);
}, 500);
}
async.waterfall([
function(cb){
finder([1, 2], cb);
},
processor
,
function(records, cb) {
alert(records);
}
]);