angular-es-utils
Advanced tools
Comparing version 2.1.1 to 2.1.2
@@ -77,5 +77,2 @@ 'use strict'; | ||
dispatch: function dispatch(topic) { | ||
var listeners = topics[topic] || []; | ||
for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
@@ -85,11 +82,23 @@ args[_key2 - 1] = arguments[_key2]; | ||
for (var i = 0; i < listeners.length; i++) { | ||
var listeners = topics[topic] || []; | ||
var listenersToBeRemoved = []; | ||
if ((0, _typeAuth.isFunction)(listeners[i])) { | ||
listeners[i].apply(null, args); | ||
listeners.forEach(function (listener) { | ||
if (listener === null) { | ||
listenersToBeRemoved.push(listener); | ||
} else { | ||
console.error('事件总线分发 %s 消息失败,注册的listener不是函数类型!', topic); | ||
if ((0, _typeAuth.isFunction)(listener)) { | ||
listener.apply(null, args); | ||
} else { | ||
console.error('事件总线分发 %s 消息失败,注册的listener不是函数类型!', topic); | ||
} | ||
} | ||
} | ||
}); | ||
// 清空空值的 listener | ||
listenersToBeRemoved.forEach(function (emptyListener) { | ||
return listeners.splice(listeners.indexOf(emptyListener), 1); | ||
}); | ||
return this; | ||
@@ -96,0 +105,0 @@ }, |
{ | ||
"name": "angular-es-utils", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "es utils design for angular1.x", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
30441
674