0.1.2 • Published 7 years ago

redux-dispatch-batch-middleware v0.1.2

Weekly downloads
5
License
ISC
Repository
github
Last release
7 years ago

redux-dispatch-batch-middleware

Middleware that allows to dispatch an array of actions

Installation

yarn add redux-dispatch-batch-middleware

or (if you are not using Yarn, but hope you do :wink:)

npm i redux-dispatch-batch-middleware

Usage

In place where your createStore lives:

import { createStore, applyMiddleware } from 'redux';
import dispatchBatchMiddleware from 'redux-dispatch-batch-middleware';

const createStoreWithMiddlewares = applyMiddleware(
    // ... all your middlewares
    dispatchBatchMiddleware,
)(createStore);

and now you can dispatch your actions like this:

dispatch([
    oneAction(),
    anotherOneAction(someArgs),
    andAllOthersThatYouNeed(),
]);

:tada:

p.s. And of course you can still dispatch like this:

dispatch(something());