I have been working with async.waterfall and nodejs. Its working very well but now I have a question about flow.
I want to use a simple if condition in async.waterfall flow.
async.waterfall([
callOne,
callTwo,
if(condition > 0 ) {
callTest1,
callTest2,
}else{
callTest3,
callTest4,
}
callThree,
callFour,
callFive,
], function (err, result) {
if (err) {
return res.status(400).jsonp({error: err});
}
});
I just want to test for one condition ..
If it is condition is true
then run a few functions
else
run other functions.
endif
cleanup
I was trying this too...one async.waterfall calling two async.waterfall/s
router.post('/testUser', function (req, res, next) {
......
function validateAccount(callback) {
if (config.CHECK_EMAIL_MEMBER_ID > 0) {
async.waterfall([
callOne,
callTwo,
if(condition > 0 ) {
callTest1,
callTest2,
}else{
callTest3,
callTest4,
}
callThree,
callFour,
callFive,
], function (err, result) {
if (err) {
return res.status(400).jsonp({error: err});
}
});
} else {
async.waterfall([
callOneb,
callTwob,
if(condition > 0 ) {
callTest1b,
callTest2b,
}else{
callTest3b,
callTest4b,
}
callThreeb,
callFourb,
callFiveb,
], function (err, result) {
if (err) {
return res.status(400).jsonp({error: err});
}
});
}
}
async.waterfall([
setupUser,
testOne,
validateAccount,
sendEmail,
], function (err, result) {
if (err) {
return res.status(400).jsonp({error: err});
}
});
});
function (results) { callback(results); }
withcallback
– Vole