This library is designed for Runnel. Please visit our documentation and learn more.
const { register, unregister, subscribe } = createPlugin(deepEqual);
const eventBus = createEventBus({
deepEqual,
payloadValidator,
});
register();
...
// Example with React.useState
const [metrics, setMetrics] = useState();
subscribe(setMetrics);
-
topic1
with schema{ "type": "number" }
. - No subscribers.
- One publishing event with payload
100
.
{
"topic1": {
"onPublishCreated": 1,
"onPublish": 100,
"onSubscribeCreated": 0,
"onSubscribe": null
}
}
-
topic2
with schema{ "type": "string" }
. - One subscriber.
- No publishing events.
{
"topic2": {
"onPublishCreated": 0,
"onPublish": null,
"onSubscribeCreated": 1,
"onSubscribe": null
}
}