@sergicontre/pubsub
v0.1.0
Published
A tiny Publish-Subcribe pattern
Downloads
3
Readme
@sergicontre/pubsub
A tiny Publish-Subcribe pattern to define a one-to-many dependency between objects so that when one object change state, all its dependents are notified and updated automatically.
Install
$ npm install @sergicontre/pubsub
Usage
import PubSub from "@sergicontre/pubsub";
publish
PubSub.publish("channel-name", value);
subscribe
//Return Observable
let subscriber = PubSub.subscribe("channel-test").on((value) => {
console.log(`value: ${value}`);
});
unsubscribe
//Return Observable
let subscriber = PubSub.subscribe("channel-test").on((value) => {
console.log(`value: ${value}`);
});
subscriber.unsubscribe();