wtc-sub-middleware

We The Curious actions subscription middleware

Usage no npm install needed!

<script type="module">
  import wtcSubMiddleware from 'https://cdn.skypack.dev/wtc-sub-middleware';
</script>

README

We The Curious actions middleware

This is a piece of middleware used in react redux app to pass actions to a broker via MQTT.

How to use:

import { createMQTTMiddleware } from 'wtc-sub-middleware'
createMQTTMiddleware('http://localhost:1884', '--origin--')

Origin is an optional parameter that gets added to final published output

Accepts a url parameter, publishes current action, and then passes that same action back into the store.

By default subscribed to all actions, can be changed to subscribe to specific list of action like so:

client.subscribe(['BUTTON_PRESS', 'TOGGLE_SWITCH'])

Some basic error catchers. Looks for a broker connection every 10s.