Skip to content

jiggum/redux-batched-dispatch

Repository files navigation

redux-batched-dispatch

Redux store enhancer to allow batched dispatch.

npm Build Status min minzip

Installation

yarn:

yarn add redux-batched-dispatch

npm:

npm install --save redux-batched-dispatch

Usage

Standard

import reduxBatchedDispatch  from 'redux-batched-dispatch';
import { createStore } from 'redux';

const store = createStore(reducer, reduxBatchedDispatch());

// Batched dispatch will notify to listeners only once after store updated
store.dispatch([
  { type: 'Hello' },
  { type: 'World' },
]);

With middlewares

You can use extra middlewares like redux-thunk, redux-saga, redux-observable, etc..

import reduxBatchedDispatch  from 'redux-batched-dispatch';
import { createStore, applyMiddleware } from 'redux';

const store = createStore(
  reducer,
  reduxBatchedDispatch(applyMiddleware(exampleMiddleware))
);

Module Usage

ES6 module

import reduxBatchedDispatch from 'redux-batched-dispatch';

CommonJS

const reduxBatchedDispatch = require('redux-batched-dispatch');

Browser

Add below <script> tag to the HTML page right before the closing </body> tag

<script src="https://unpkg.com/redux-batched-dispatch@0.3/dist/index.js" crossorigin></script>

And use global reduxBatchedDispatch variable