minsky-blmanager
v1.1.1
Published
Binded listeners manager
Downloads
24
Readme
BLManager
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
Dependencies
- Core - 1.1.0
Getting started
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));
Constructor Parameters
… Core constructor parameters
Interface
Options
scope
Type: Object/Function
Default: self
Scope to be bound to the methods when add is called.
Properties
… Core properties
Methods
add
Parameters: name, listener [, scope]
Return: Function
Keeps track of the bound listener using a name, duplicates will override each other, returns the bound listener
get
Parameters: name
Return: Function
Returns the bound listener that corresponds with the given name
remove
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.
destroy
Parameters: none
Return: none
Clears listener data and destroys the instance
Changelog
1.1.0
- Corrected way of returning bound listeners on remove
- Made properties private
- Listener types changed to arrays for more intuitive listener management.
1.0.0
- Creation of class