Pot.Deferred.prototype.canceller

{Pot.Deferred|Array} Pot.Deferred.prototype.canceller ({Function} func)

Pot.js と PotLite.js で利用可能。

Deferred チェインのキャンセル時に実行される関数を登録 または取得します。

キャンセル時に実行される関数を登録、または取得します。
cancel() が呼ばれた時に実行される関数を登録します。
canceller はスタッカブルに関数を保持しているため、 複数の関数を登録することができます。
引数を省略して実行した場合、登録済みの関数を持つ配列が返ります。

実行時の Pot.Deferred インスタンスが返ります。
引数に何も与えずに実行した場合、登録済みの関数を持つ配列が返ります。

var d = new Pot.Deferred();

d.canceller(function() {
    debug('cancelled!');
}).canceller(function() {
    debug('cancelled!!');
}).then(function() {
    debug('start chain');
});
d.cancel();
// cancelled!
// cancelled!!
// と出力される