I have this Typescript / Javascript function:
wordFormRowClicked = (wf): ng.IPromise<any> => {
var self = this;
if (this.wordFormIdentity != wf.wordFormIdentity) {
angular.forEach(self.word.wordForms, function (wf, key) {
var wordFormNgForm = 'wordFormNgForm_' + wf.wordFormIdentity;
if (self[wordFormNgForm].$pristine) {
;
} else {
self.wordFormUpdate(wf).then((): any => {
self[wordFormNgForm].$setPristine();
});
}
});
this.wordFormIdentity = wf.wordFormIdentity;
}
}
self.wordFormUpdate(wf) returns a promise and so gives the correct return types but if wordFormUpdate is not called then it does not return a promise and also there is a possibility that multiple wordFormUpdates will be called and I have to ensure they have all finished before returning.
Can anyone suggest how I can do this?