Use invokeAndRemove instead of invoke and removeAll

This commit is contained in:
pandamicro
2016-02-29 15:06:17 +08:00
parent 535ed9406d
commit 68371c5ff5
2 changed files with 4 additions and 4 deletions
+1 -4
View File
@@ -390,10 +390,7 @@ JS.mixin(Pipeline.prototype, {
this.complete();
items.invoke(url, item);
// remove all callbacks added for url
items.removeAll(url);
items.invokeAndRemove(url, item);
},
/**
@@ -219,6 +219,7 @@ CallbacksInvoker.prototype.invoke = function (key, p1, p2, p3, p4, p5) {
* @param {any} [p5]
*/
CallbacksInvoker.prototype.invokeAndRemove = function (key, p1, p2, p3, p4, p5) {
this._invoking = key;
// this.invoke(key, p1, p2, p3, p4, p5);
// 这里不直接调用invoke仅仅是为了减少调用堆栈的深度,方便调试
var list = this._callbackTable[key], i, l, target;
@@ -235,6 +236,8 @@ CallbacksInvoker.prototype.invokeAndRemove = function (key, p1, p2, p3, p4, p5)
}
}
}
this._invoking = null;
this._toRemove.length = 0;
this.removeAll(key);
};