1.0.1 • Published 8 years ago

redux-action-enhancer-middleware v1.0.1

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

redux-action-enhancer-middleware

Middleware that provides an enhancing function to dispatched actions, with optional filtering to target only certain actions.

Install

npm i -S redux-action-enhancer-middleware

Example

import actionEnhancerMiddleware from 'redux-action-enhancer-middleware';

const options = {
  filter: (action) => true,
  enhancer: (dispatch, getState, action) => {...action}
};

const store = createStore(
  reducer,
  applyMiddleware(
    actionEnhancerMiddleware(options)
  )
);

API

redux-action-enhancer-middleware takes an options object with an optional filter and a required enhancer.

Filter

(action) => true

Function that receive an action and returns a boolean that determines if the enhancer should be invoked.

Enhancer

(dispatch, getState, action) => nextAction

Function that receives a dispatch, getState, and action. The enhancer returns an action.