@mongodb-js/hadron-app-registry-redux-middleware
Redux middleware for interfacing with the Hadron App Registry
Last updated 3 years ago by matt_d_rat .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @mongodb-js/hadron-app-registry-redux-middleware 
SYNC missed versions from official npm registry.

hadron-app-registry-redux-middleware

Redux middleware which wraps the Hadron App Registry to facilitate the integration between Hadron App components which may use different state or store implementations (eg: Reflux, MobX).

The middleware listens to relevant Hadron App Registry events and dispatches them as Redux actions. It is also able to intercept relevant dispatched Redux actions and emit them as events in the Hadron App Registry.

Getting Started

$ npm install --save @mongodb-js/hadron-app-registry-redux-middleware

or

$ yarn add @mongodb-js/hadron-app-registry-redux-middleware

Alternatively, you may use the provided UMD builds directly in the <script> tag of an HTML page.

Usage Example

Create and apply the middleware to the Redux store, passing an instance of the hadron-app-registry as the first argument, along with any mappings for eventsToActions and actionsToEvents.

import { createStore, applyMiddleware } from 'redux';
import AppRegistry from 'hadron-app-registry';
import hadronAppRegistryReduxMiddleware from '@mongodb-js/hadron-app-registry-redux-middleware';
import reducers from './reducers';

const appRegistry = new AppRegistry();

// map appRegistry event names (key) to Redux action types (value)
const eventsToActions = {
  'foo': 'BAR'
};

// map Redux action types (key) to appRegistry event names (value)
const actionsToEvents = {
  'FIZZ': 'buzz'
};

let store = createStore(
  reducers,
  applyMiddleware(
    hadronAppRegistryReduxMiddleware(
      appRegistry,
      eventsToActions,
      actionsToEvents
    )
  )
);

Demo Example

This project also includes an example demonstrating the middleware in action:

To run the demo, clone this project and execute the following:

$: cd ./examples/react
$: npm install
$: npm start

Change Log

This project adheres to Semantic Versioning. Every release, along with the migration instructions, is documented on the Github Releases page.

License

Apache 2.0

Current Tags

  • 1.0.1                                ...           latest (3 years ago)

1 Versions

  • 1.0.1                                ...           3 years ago

Copyright 2014 - 2016 © taobao.org |