You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tiny module for Storeon which is adding undo functionality to your state. This means that now you can undoing or redoing the events in the state.
It is just 377 bytes module (it uses Size Limit to control the size) without any dependencies.
import{undoable,UNDO,REDO}from"@storeon/undo/full";conststore=createStore([/* all your modules */undoable,]);// now you can use UNDO and REDO with dispatchdispatch(UNDO);
Installation
npm install @storeon/undo
# or
yarn add @storeon/undo
If you need history only for some particular keys in state you can use createHistory function:
import{createHistory}from"@storeon/undo";// history will be collect only for key `a`consthistory=createHistory(["a"]);const{UNDO,REDO}=history;createStore([/* all your modules */history.module,]);// to change the history use the UNDO and REDO from `history` objectdispatch(UNDO);
API
createHistory(paths, config)
paths parameter
typepaths=Array<String>;
The keys of state object that will be stored in history
config parameter
typeconfig.key=String
The default state key for storing history, when omitted:
if paths is not empty will be generated based on paths content