@devinle/sonar
v1.0.24
Published
A lightweight PubSub utility
Downloads
4
Readme
Sonar
A lightweight PubSub utility.
Install
npm install @devinle/sonar
Usage
import { sonar } from 'sonar';
// Make a callback function
const callback = data => {};
// Register a callback with an event
// This event can receive data
sonar.on('evt', callback);
// Remove a specific callback from an event
sonar.off('evt', callback);
// Remove an entire event and all associated callbacks
sonar.off('evt');
// Trigger an event and send a payload object
sonar.trigger('evt', {...});
Tests
yarn test