Reputation: 679
I am facing issue in my project. I have to send 5 calls to database. after Sequence: 1 -> 2-> 3,4,5
i am using shared app.factory service for call. i am unable to do so. i am using angularjs. if i do async:false, all calls will be async and this will take time. if i make it true, my 1->2 call repsond late, and 3,4,5 calls respond very early.
app.factory have shared success call for proc1, proc2,proc3,proc4,and proc5.
i want to execute 1->2 calls and then 3,4,5 parallel.
thanks
Upvotes: 0
Views: 113
Reputation: 6620
Your calls to the database need to return promises, which can then be chained together.
var result = service.call1(args)
.then(function(){return service.call2;})
.then(function($q){
var promises = [
service.call3,
service.call4,
service.call5
];
return $q.all(promises);
});
Without seeing any of your code structure this is about as specific as I can get, but it should be enough to show you what to do.
Upvotes: 1