views:

44

answers:

1

Is there any way to unregister callbacks from dojo.Deferred? If not why?

A: 

According to this, there isn't. Shouldn't be too hard to add one though:

dojo.Deferred.prototype.removeCallback = function(fn) {
    for (var c = this.chain, i = c.length; i--;)
        if (c[i][0] === fn) c.splice(i, 1);
    return this;
};

Usage:

var d = new dojo.Deferred;
d.addCallback(someFn);
// Remove it:
d.removeCallback(someFn);
J-P