CURIOS MIDDLEWARE REDUX SERIAL
Rationale
This middleware will establish a connection to brightsign serial ports and allow communication with physical hardware through the dispatch of specially formed redux action.
If not connected to brightsign it will fall back to a non functional stub which will simulate response from devices
Installation
npm i -s @wethecurious/curios-reduxmiddleware-serial
At your createStore
import { createSerialMiddleware } from 'redux-middleware-serial'
const serial = createSerialMiddleware()
const store = createStore(
reducer,
applyMiddleware(serial)
)
store.dispatch({typeL'@@CURIOS_INIT'}) // this is the desfault action which tells the serial to attempt to connect
Dispatching a Serial Action
Just dispatch a normal action with bus: 'SERIAL' in the target the payload will have a serial
store.dispatch({
type: 'ACTION',
target: {
bus: 'SERIAL',
channel: 1,
}
payload:{
state: 'ON', // The state of the device depending on the device API
}
})
There will be two actions dispatched from the middleware, on attempting to send across the serial bus and on return.
{
type: '@@CURIOUS_BUS_SERIAL_SEND'
}
{
type: '@@CURIOUS_BUS_SERIAL_RETURN'
}