diff --git a/Event/EventManager.js b/Event/EventManager.js index 19ccdc0..a644311 100644 --- a/Event/EventManager.js +++ b/Event/EventManager.js @@ -104,12 +104,31 @@ this.callbacks[group].func(); if (this.callbacks[group].remove) { - delete this.callbacks[group]; - delete this.groups[group]; + this.detach(group); } } }; + /** + * Detach event + * + * @param {string|int} group Group id + * @param {function} callback Callback + * @param {boolean} remove Should be removed after execution + * + * @return {void} + * + * @method + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + jsOMS.Event.EventManager.prototype.detach = function (group) + { + delete this.callbacks[group]; + delete this.groups[group]; + }; + /** * Attach callback to event group * @@ -117,7 +136,7 @@ * @param {function} callback Callback * @param {boolean} remove Should be removed after execution * - * @return {boolean} + * @return {void} * * @method * @@ -130,4 +149,19 @@ this.callbacks[group] = {remove: remove, func: callback}; }; + + /** + * Count events + * + * @return {int} + * + * @method + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + jsOMS.Event.EventManager.prototype.count = function () + { + return this.callbacks.length; + }; }(window.jsOMS = window.jsOMS || {}));