Add removeHook method.
- Removes a previously attached hook. - Must be the SAME function to unregister.
This commit is contained in:
parent
2f781dab81
commit
05a84c6630
@ -104,3 +104,12 @@ window.addHook = function(event, callback) {
|
||||
else
|
||||
_hooks[event].push(callback);
|
||||
}
|
||||
|
||||
// callback must the SAME function to be unregistered.
|
||||
window.removeHook = function(event, callback) {
|
||||
if (typeof callback !== 'function') throw('Callback must be a function.');
|
||||
|
||||
if (_hooks[event]) {
|
||||
_hooks[event].splice(_hooks[event].indexOf(callback), 1);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user