Skip to content

devinle/sonar

Repository files navigation

Sonar

A lightweight PubSub utility.

npm NPM GitHub last commit

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

License

MIT

About

A lightweight PubSub utility

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published