Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/unlight/onn

Event emitter using DOM's addEventListener/dispatchEvent
https://github.com/unlight/onn

bus emit-events emitter event-emitter eventbus events pubsub

Last synced: 6 days ago
JSON representation

Event emitter using DOM's addEventListener/dispatchEvent

Awesome Lists containing this project

README

        

# onn
Event emitter using DOM's addEventListener/dispatchEvent

## Usage
```js
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
```