2

Say I have a promise and I use .then to wait for it to resolve,

var suc = function(){ console.log('promise ended') } 
var err = function(e){ console.log('promise ended') }

promise.then( suc, err );
>> promise ended
>> promise ended

What if I do not care if It succedes or fails? I just want to know it was completed.

promise.both(function(){console.log('next')}

Is there such a function?

lonewarrior556
  • 3,917
  • 2
  • 26
  • 55

2 Answers2

2

Could use .then() prior to calling suc or err

var completed = function() { console.log('next') };

promise.then(completed, completed).then(suc, err)
guest271314
  • 1
  • 15
  • 104
  • 177
  • See also http://stackoverflow.com/questions/35042068/why-is-onrejected-not-called-following-promise-all-where-promise-reject-incl – guest271314 Feb 12 '16 at 17:42
1

You can do something like this:

promise.catch(function() {}).then(function() { console.log('DONE'); });
Marco Castelluccio
  • 10,152
  • 2
  • 33
  • 48