redux-custom-middlewares

    1.0.2 • Public • Published

    redux-custom-middlewares

    middlewares inside your FSA actions

    Motivations

    redux-custom-middlewares allow you to dispatch middlewares inside your FSA actions. it's like super thunk !

    Goals

    • dispatch plain object actions which handle side effects
    • have a contextual use of middlewares
    • create redux modules

    Installation

    npm install --save redux-custom-middlewares
    
    import { createStore, applyMiddleware } from 'redux';
    import { installCustomMiddlewares } from 'redux-custom-middlewares';
    import rootReducer from './reducers';
    const initialState = {};
     
    const store = createStore(rootReducer, initialState applyMiddleware(installCustomMiddlewares()))

    Usage

    import { customMiddleware } from 'redux-custom-middlewares';
     
    // this custom middleware just console.log the current action
    const withLoggerMiddleware = customMiddleware(
        () => next => action => {
            console.log(action);
            return next(action);
        };
    );
     
    const myActionCreator = withLoggerMiddleware((param) => ({
        type: 'MY_ACTION',
        payload: param,
    }));

    Contributing

    If you like this module, you're welcome for contributing, take a look at CONTRIBUTING.md

    Install

    npm i redux-custom-middlewares

    DownloadsWeekly Downloads

    3

    Version

    1.0.2

    License

    MIT

    Last publish

    Collaborators

    • trapcodien