@jumpfox/broker
Message Broker for javascript applications
request or import Broker in your code and call
-
subscribe
to create a subscription to a topic with a callback to handle the incoming messages -
publish
to publish a message to other listeners -
unsubscribe
to stop listening to a topic
Usage
import {Broker} from '@jumpfoxltd/broker';
or
const {Broker} = require('@jumpfoxltd/broker');
Subscribe
const topic = 'test-topic';
cost cb = (payload)=>{
// the payload can be anything that you want to consume
}
Broker.subscribe(topic,cb);
Publish
In order publish a topic , you have to subscribe a topic first and then you can publish anything you want to it
const topic = 'test-topic';
Broker.publish(topic,{data:'test'});
Unsubscribe
const topic = 'test-topic';
cost cb = (payload)=>{
// the payload can be anything that you want to consume
}
Broker.unsubscribe(topic,cb);