@arturdoruch/event-registry
v1.0.3
Published
DOM element events registry
Downloads
6
Maintainers
Readme
Event registry
DOM element events registry.
Install
yarn add @arturdoruch/event-registry
Usage
import eventRegistry from '@arturdoruch/event-registry';
function consoleListener(e, firstArgument, secondArgument) {
console.log(firstArgument);
console.log(secondArgument);
}
// Register event listener to the DOM element.
const eventId = eventRegistry.on('click', 'h1', consoleListener, ['firstArgument', 'secondArgument']);
// Trigger event manually.
eventRegistry.trigger(eventId);
// Remove event listener.
//eventRegistry.off(eventId);
// Register event listener to the DOM element, which will be called only once.
//eventRegistry.one();