redocer

1.0.1 • Public • Published

Redocer

Pronounced: reducer

A custom reducer enhancer that returns a reducer that handles undo and redo actions.

API

import makeRedocer from 'redocer'
 
function reducer(state, action) { ... };
 
let redoable = makeRedocer(reducer, initialState);
 
// Regular actions pass through to the original reducer
redoable(state, 'some-action')
// if you have already called the reducer with a custom action
// then you can call it with a `redo` action, returning the previous state
redoable(state, 'redo')
// Once you have redone a change, you can call the reducer with `undo`
redoable(state, 'undo')

Readme

Keywords

none

Package Sidebar

Install

npm i redocer

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

9.88 kB

Total Files

10

Last publish

Collaborators

  • matthamlin