makler
v1.0.0
Published
Buffered, multi-topic message broker
Downloads
6
Maintainers
Readme
Makler
Multi topic message broker
Makler is a functional multi topic buffered message broker written in TypeScript. It runs in the browser, or on the server using node.js.
Setup
yarn add makler
or
npm install --save makler
Usage
Before you start import the library
import { create, topic, publish, subscribe } from 'makler'
Basic usage
// Setup a new bus with no buffer
const broker = create()
const chan = topic(broker, ['topic'])
// Data published can be anything
const context = { test: true }
// Setup a subscriber
const ubsubscribe = subscribe(broker, (data, topic) => {
console.log(data, topic) // { test: true } ["topic"]
})
// Publish some data
publish(chan, context)
// Cleanup
unsubsribe()