I am returning a promise from such a function:
resultPromise = dgps.utils.save(opportunity, '/api/Opportunity/Save', opportunity.dirtyFlag).then(function () { self.checklist.saveChecklist(opportunity).then(function () { self.competitor.save(opportunity.selectedCompetitor()).then(function ... etc. return resultPromise;
Say the above function is called save.
In the calling function, I want to wait until the entire chain is complete and then do something. My code looks like this:
var savePromise = self.save(); savePromise.then(function() { console.log('aftersave'); });
As a result, the aftersave is sent to the console, and the promises chain still works.
How can I do something after completing the whole chain?
Rollingand
source share