1.0.2 • Published 5 years ago
miluna-pubsub v1.0.2
miluna-pubsub
A simple publisher-subscriber for JavaScript written in TypeScript
Download
miluna-pubsub is available through npm. You can download this package using the following command
npm i miluna-pubsub
Use case
You create a subscription to a topic and asign a callback to that subscription. Once there's a publish call to that topic, all the subscribers will do its callback.
import { subscribe, publish, unsubscribe } from "miluna-pubsub";
// create subscription
const subscription = subscribe("test", (arg) => console.log(arg));
// send payload
publish("test", "payload");
// unsubscribe from topic
unsubscribe("test", subscription);