npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@wethecurious/curios-reduxmiddleware

v0.0.8

Published

A redux middleware for communication with Curios services

Downloads

2

Readme

CuriOs redux middleware

This collection of middlewares is designed to provide a redux friendly connection to We The Curious's CuriOs services for exhibit's implementing the redux pattern. The middleware handles connection to and data retrival from:

  • mqtt iot devices
  • phidget physical input devices
  • exhibit analytics service

Usage

The createCuriosMiddleware export both a middleware and wrapped version of the redux combineReducer function which provides the '@@Curios' reducer to track connection state in the redux store

Changes

v0.0.8

  • Added options to useCurios hook to optionally attempt to parse bus data as json

v0.0.6

  • Changed phidget actions to correctly handle disconnect and reconnection of devices

  • TODO: make sure the reducer updates to reflect both channel and connection status

Config

{
    app: 'example', //app name as supplied by wtc
    appInstance: 0, //instance of the app, used when more than one app connects to the same broker
    service: 'test', //service name
    serviceInstance: 0 //instance of the service, used in there is more than one instance of the service in the app
    serviceVersion: '0.1', //version of the service
    env: 'production', //initialise the middleware in development or production mode
    mqtt: { // mqtt broker connection details
        host: 'localhost',
        port: 3000,
    },
    phidget: [ //phidget details, mulitple phidgets may be connected by providing and array on connection details
        {
            host: 'localhost',
            port: 5166,
            isMqttMock: false //Optional: If a phidget is not avaliable use mqtt as a mock, in this case it will subscribe to mock/phidget/{name}
            devices: [{
                type: 'ENCODER'
                name: 'encoder1'
                channel: 0
            }] //an array of device connected to the VINT ports of the phidget. Only 'ENCODER' and 'VOLTAGE RATIO ARE currently avliable.
        }
    ]
}

Create the Functions and the Store

   const [useCurios, middleware, combineReducers] = createCuriosMiddleware(config)

   const store = createStore(
        combineReducers({...otherReducers}),
        applyMiddleware(...middleware)
   )

Initalise the middleware

    store.dispatch({type: '@@CURIOS_INIT'})

Reset the session

Once an app has been initialised a new session should be created everytime the application resets to attract mode

    store.dispatch({type: '@@CURIOS_SESSION'})

To get the data from the mqtt or phidget bus

The useCurios hook can be used inside a component to get data coming on the bus.

const busData = useCurios()

You can select a component to only update on new data by using a selector function, eg:

const busData = useCurios(state => state[selectedDevice])

You can optionally pass options

const options = {
    parseAsJson: true
}

const busData = useCurios(state => state[selectedDevice], options)

To mock phidget info with mqtt

If a phidget is not avaliable you can use mqtt as a mock by setting isMqttMock: true in the phidget device config. In this case it will subscribe to mock/phidget/{name}

Coming next

  • [x] ~~Better selection of params from useCurios~~

  • [x] ~~More control over phidget devices and ports. Currently it is not easy to choose which device is running on which VINT port~~

  • [x] ~~MQTT mock system for when phidget hardware is not avaliable~~

  • AWS IoT intergration for analytics

  • Less pollution of redux dispatch list when mqtt can't connect

  • Support for more phidget devices