Skip to content
This repository has been archived by the owner on Dec 16, 2020. It is now read-only.

Latest commit

 

History

History
63 lines (37 loc) · 1.15 KB

README.md

File metadata and controls

63 lines (37 loc) · 1.15 KB

redux-batch-middleware

Batch Redux actions

npm version

Batch middleware for Redux. Inspired by redux-batched-actions.

Install

Using npm.

npm install --save redux-batch-middleware

Using yarn.

yarn add redux-batch-middleware

Usage

Add as middleware:

import { applyMiddleware, createStore } from 'redux';
import { batch, batching } from 'redux-batch-middleware';
import reducers from './reducers';

const middleware = [batch];

const store = createStore(batching(root), applyMiddleware(...middleware));;

Dispatch multiple actions:

store.dispatch([action1, action2]);

API

batch

Redux middleware which converts a dispatched array of actions to a batch action.

batching(reducer)

reducer

Type: function

A reducer that should be able to handle batched actions, most likely the root reducer.

type

The name of the batch type.

License

MIT