@avidian/events
v1.0.3
Published
A pub/sub library for handling events.
Downloads
4
Readme
@avidian/events
A pub/sub library for handling events.
Installation
NPM
npm install @avidian/events
Yarn
yarn add @avidian/events
Usage
import { Manager } from '@avidian/events';
const manager = new Manager();
// listen to events
const key = manager.on('my_event_key', (value) => {
console.log(value);
}); // or manager.listen(name, callback)
// dispatch values to events
manager.dispatch('my_event_key', 'value');
// unlisten specific key to events
manager.off(key); // or manager.unlisten(key)
// clear all listeners
manager.clear();