Event binding management for your projects Bound listeners are hard to unbind when developement hasn’t kept them aside. This class helps to manage it all without having to rewrite the logic every time.
Class type: Manager
- Core - 1.1.0
const mgr = new BLManager({
scope: this
});
// bind listeners tot he current scope
$domElement.addEventListener('click', mgr.add('domClick', domClick));
$domElement.removeEventListener('click', mgr.add('domClick', domClick));
… Core constructor parameters
Type: Object/Function
Default: self
Scope to be bound to the methods when add is called.
… Core properties
Parameters: name, listener [, scope]
Return: Function
Keeps track of the bound listener using a name, duplicates will override each other, returns the bound listener
Parameters: name
Return: Function
Returns the bound listener that corresponds with the given name
Parameters: name
Return: Function
Removes the listener that corresponds with the given name, returns the found bound listener for further use outside of the manager.
Parameters: none
Return: none
Clears listener data and destroys the instance
- Corrected way of returning bound listeners on remove
- Made properties private
- Listener types changed to arrays for more intuitive listener management.
- Creation of class