then

  • function
can.Deferred.prototype.then  

Add callbacks to a Deferred.

deferred.then(doneCallback[, failCallback])

Parameters

  1. doneCallback {function()}

    A function called when the Deferred is resolved.

  2. failCallback {function()}Optional

    A function called when the Deferred is rejected.

deferred.then(doneCallback, failCallback) adds handler(s) to be called when the Deferred object to be called after its resolved.

var def = can.Deferred();
def.then(function(success) {
    console.log(success);
}, function(reason) {
    console.error(reason); //-> "Oh no! So sad."
});

def.reject("Oh no! So sad.");