@farolan/redux-batch-enhancer

0.1.4 • Public • Published

redux-batch-enhancer

Store enhancer and action creator that enables batching subscriber notifications for an array of actions, including complex actions (e.g. thunks) enabled by middleware. Inspired by redux-batched-actions and redux-batched-subscribe.

Installation

npm install --save redux-batch-enhancer

Then to enable, apply the provided store enhancer (batchStoreEnhancer) and middleware (batchMiddleware):

import { createStore } from 'redux'
import { batchStoreEnhancer, batchMiddleware } from 'redux-batch-enhancer'

const store = createStore(
  reducer,
  compose(
    applyMiddleware(batchMiddleware, thunk, logger, perflogger),
    batchStoreEnhancer,
  )
);

Note: batchStoreEnhancer overwrites dispatch and subscribe on the original redux store, and thus must be applied before any middleware or store enhancers that depend on these two methods.

Example Usage

import { batchActions } from 'redux-batch-enhancer'

dispatch(batchActions([{ type: 'vanillaAction' }, createThunkAction()]));

/@farolan/redux-batch-enhancer/

    Package Sidebar

    Install

    npm i @farolan/redux-batch-enhancer

    Weekly Downloads

    1

    Version

    0.1.4

    License

    MIT

    Unpacked Size

    5.16 kB

    Total Files

    4

    Last publish

    Collaborators

    • farolan