防止删除一个空的函数发生未定义报错

This commit is contained in:
yhh
2020-07-15 10:56:06 +08:00
parent dd65c60921
commit 13e7737cb9
5 changed files with 8 additions and 5 deletions

View File

@@ -34,7 +34,8 @@ class Emitter<T> {
public removeObserver(eventType: T, handler: Function){
let messageData = this._messageTable.get(eventType);
let index = messageData.findIndex(data => data.func == handler);
messageData.removeAt(index);
if (index != -1)
messageData.removeAt(index);
}
/**