rejectWith

  • function
can.Deferred.prototype.rejectWith  

Reject a Deferred in a particular context.

deferred.rejectWith(context[, arguments])

Parameters

  1. context {Object}

    Context passed to the failCallbacks as the this object.

  2. arguments {Array}Optional

    Array of arguments that are passed to the failCallback(s).

deferred.rejectWith(context, arguments) rejects a Deferred and calls the failCallbacks with the given arguments.

var def = can.Deferred();
def.fail(function(error) {
    this.logError(error); //-> "Oh no!"
});

var context = {
    logError: function(error) {
        console.error(error);
    }
};
def.rejectWith(context, ["Oh no!"]);