I am working on an application that heavily depends on asynchronous data operations. I am dealing with those through promises.
However, while my code works, I have the feel that it is getting chaotic and hard to maintain in the future.
Assume this:
validate().then(
// success
function(promise){
$http.post('stuff.php',data).then(
function(p){
},
function(){
}
)
},
// failure
function(reason){
// Assume another promise-depending operation
},
// notification
function(update){
}
);
As you can see, promise calls are heavily nested. Furthermore, I have to deal with resolve/reject methods in each and every step.
What am I missing; how can I improve my technique?