0.1.1 • Published 8 years ago

redux-reactor v0.1.1

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

Redux Reactor

NOTE: This is still work in progress..

Side-effect middleware for Redux.

build status npm version

npm install --save redux-reactor

ES modules:

import reactor from 'redux-reactor'

CommonJS:

const reactor = require('redux-reactor').default;

As you can see, if you use CommonJS require it also requires .default at the end.

Why Do I Need This?

If you’re not sure whether you need it, you probably don’t.

Reactors can be used to orchestrate asynchronous flows in your redux application. See examples for use cases.

Motivation

Redux Reactor allows you wait for actions to be dispatched and react to them (in whatever way you like) and if applicable, dispatch new actions. The tools you are given are takeDispatchOf and takeEveryDispatchOf that you are expected to use together with async / await from ESNext.

Examples

Examples 1:

// ... Examples coming

Installation

npm install --save redux-reactor

Then, to enable Redux Reactor, use applyMiddleware():

import { createStore, applyMiddleware } from 'redux';
import reactor from 'redux-reactor';
import rootReducer from './reducers/index';

// Import your reactors
import { myReactor, myOtherReactor } from './reactors';

// Note: this API requires redux@>=3.1.0
const store = createStore(
  rootReducer,
  applyMiddleware(
    reactor([
      myReactor,
      myOtherReactor
    ])
  )
);

License

MIT