@wethecurious/curios-reduxmiddleware-serial
TypeScript icon, indicating that this package has built-in type declarations

0.0.13 • Public • Published

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'
}

Readme

Keywords

none

Package Sidebar

Install

npm i @wethecurious/curios-reduxmiddleware-serial

Weekly Downloads

13

Version

0.0.13

License

GPL

Unpacked Size

7.8 kB

Total Files

6

Last publish

Collaborators

  • makorantz
  • shved90
  • benvium