redux-buffered-reducer

1.0.0 • Public • Published

redux-buffered-reducer

A simple reducer enhancer to buffer changes.

Usage

Add as an npm dependency

npm install redux-buffered-reducer

Enhance your reducer:

import buffer from 'redux-buffered-reducer';
 
function myReducer(state, action) {
    // ...
}
 
const bufferedMyReducer = buffer(myReducer, 'FLUSH');

The second argument to buffer is flushActionType, which is the action type BufferedReducer will flush the buffer upon.

The state returned by the buffered reducer has a bufferedState and state properties. Suppose we buffered a simple counter reducer. After a few increment actions, the buffered reducer state might look like:

{
    bufferedState: { count: 4 },
    state: { count: 0 }
}

Readme

Keywords

none

Package Sidebar

Install

npm i redux-buffered-reducer

Weekly Downloads

1

Version

1.0.0

License

none

Last publish

Collaborators

  • bradspaulding