Home

Awesome

Redux Ensure Flux Standard Action Middleware

redux-ensure-fsa provides a middleware function to use as part of the redux dispatch chain. It is intended for use in development only to check that all actions at the end of the chain follow the Flux Standard Action protocol.

Installation

npm install @meadow/redux-ensure-fsa

Usage

import { createStore, applyMiddleware } from 'redux';
import ensureFSAMiddleware from '@meadow/redux-ensure-fsa';
import thunkMiddleware from 'redux-thunk';

let middleware = [thunkMiddleware];

if (process.env.NODE_ENV !== 'production') {
  const fsaMiddleware = ensureFSAMiddleware({
    ignore: function (action) {
      return false;
    }
  })

  middleware = [...middleware, fsaMiddleware];
}

const createStoreWithMiddleware = applyMiddleware(...middleware)(createStore);

ghit.me