I have a small dialog which should validate before close, get values from inputs and then call the callback given by dialog caller. I've realized processing inputs as function taking callback arguments, so every method in chain is asynchrone.
What I want, is to call isValid, on success callback call getValues, on success callback call okCallback. Here is my code:
var self = this
this.isValid().then(lang.hitch(this, this.getValues), function(){
console.log('Object invalid')
return false
}).then(function(item) {
self.okCallback(item)
})
The problem is, that the final then() with calling okCallback is called even if isValid() finished with error, adn getValues() were not called.
Is it normal behaviour? How to make deferred chaing, so that final success callback will be called only, if everything before succeeded?