redux-batch-buffer
Buffering redux-actions before dispatch them in the batch.
redux-batch-buffer
is a modular way to implement batching and buffering of redux actions.
Installation
npm install --save redux-batch-buffer
yarn add redux-batch-buffer
Usage
Creating store:
The redux-batch-buffer
provides own combineReducers
to be used in order
to create a redux
-store.
;; const configureStore = ;
In case when it is not accaptable to use overrided combineReduceres
you could
use High Ordered Reducer enableBatching
is also provided by redux-batch-buffer
:
;; const configureStore = ;
Dispatching actions:
The redux-batch-buffer
provides three ways to dispatch actions in a batch:
- explicitly create a batching-action and then dispatch it
- call dispatch with an array of actions (such practice could be incompatible with some middlewers)
start buffering
actions before they will be ready for dispatching and thenflush buffer
in order to proceed with state changes.
Creating the action batch expicitly:
; ;
or even in this way:
; ;
Dispatching an array of actions:
;
Buffering the actions before batch dispatching:
; ; ;;; ;
Some cases could require to not proceed with changes:
; ; ;;; ;
Middleware composition
The redux-batch-buffer
is a modular. It means that you could use only those things that
you need.
-
Batching
Just apply High Ordered Reducer
enableBatching
and then usebatch
function to createbatch
-action. -
Dispatching array of actions
Apply
enableBatching
and applyarrayToBatch
-middleware as far from reducer as it is possible. -
Buffering
Apply
enableBatching
andactionsBuffer
-middleware as close to reducers as it is possible.
For example:
;;; const appMiddlewares = thunk arrayToBatch actionsBuffer logger;