Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/unlight/onn
- Owner: unlight
- License: mit
- Created: 2019-06-23T15:45:54.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-06-23T17:52:20.000Z (over 5 years ago)
- Last Synced: 2024-08-26T05:43:50.518Z (3 months ago)
- Topics: bus, emit-events, emitter, event-emitter, eventbus, events, pubsub
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
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
```