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

gravplats/redux-batch-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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