redux-action-enhancer-middleware
v1.0.1
Published
Middleware that provides an enhancing function to dispatched actions, with optional filtering to target only certain actions.
Downloads
15
Readme
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.