This commit is contained in:
Dennis Eichhorn 2016-08-06 14:55:06 +02:00
parent 9d51b089aa
commit 4b8b17fa87

View File

@ -104,12 +104,31 @@
this.callbacks[group].func(); this.callbacks[group].func();
if (this.callbacks[group].remove) { if (this.callbacks[group].remove) {
delete this.callbacks[group]; this.detach(group);
delete this.groups[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 <d.eichhorn@oms.com>
*/
jsOMS.Event.EventManager.prototype.detach = function (group)
{
delete this.callbacks[group];
delete this.groups[group];
};
/** /**
* Attach callback to event group * Attach callback to event group
* *
@ -117,7 +136,7 @@
* @param {function} callback Callback * @param {function} callback Callback
* @param {boolean} remove Should be removed after execution * @param {boolean} remove Should be removed after execution
* *
* @return {boolean} * @return {void}
* *
* @method * @method
* *
@ -130,4 +149,19 @@
this.callbacks[group] = {remove: remove, func: callback}; this.callbacks[group] = {remove: remove, func: callback};
}; };
/**
* Count events
*
* @return {int}
*
* @method
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
jsOMS.Event.EventManager.prototype.count = function ()
{
return this.callbacks.length;
};
}(window.jsOMS = window.jsOMS || {})); }(window.jsOMS = window.jsOMS || {}));