I have a array of promises which I want to execute in sequence:
var promises = [];
promises.push(testPromise('entity1'));
promises.push(testPromise('entity2'));
promises.push(testPromise('entity'));
Q.all(promises).done(function(){
//all promises resolved;
});
dc.testPromise = function(entity){
return localForage.getItem(entity).then(function(result){
//do something with the result
});
};
I want to complete the execution of testPromise function for one entity completely before executing it for other. But I find that after localForage.getItem gets executed for entity1, the then part is not called but the function gets executed for entity2. I want the then part to be executed first before testPromise gets executed for entity2.