I have the following scenario
function testing(value, callback){
//
service(value, function first(){
if(value){
service2(function second(){
.......
callback(null);
});
}else{
service3(value, function third(){
......
service4(function fourth(){
........
callback(null);
});
});
}
});
}
Now looking at the above pseudo-code snippet, we have four different async operations. If this pattern is followed readability can become or following the functional flow path becomes difficult. How can this be improved to a cleaner structure, where abstracting/decoupling the asynchronous functions can be made cleaner?