1

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.

Bergi
  • 572,313
  • 128
  • 898
  • 1,281
user2585299
  • 863
  • 2
  • 18
  • 41

0 Answers0