A lightweight PubSub utility.
npm install @devinle/sonar
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', {...});
yarn test