onn
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i onn

Weekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

11.4 kB

Total Files

18

Last publish

Collaborators

  • iamthes