onn
v1.0.0
Published
Event emitter using DOM's addEventListener/dispatchEvent
Downloads
3
Readme
onn
Event emitter using DOM's addEventListener/dispatchEvent
Usage
const { on } = require('onn');
const off = on(document, 'login', (event) => {
console.log(`Hello, ${event.detail.name}!`); // => Hello, Bob!
});
document.dispatchEvent(new CustomEvent('login', { detail: { name: 'Bob' } }));
off(); // Unsubscribe