Skip to content

simple state-stack (undo/redo history) for fast undo redo for small reactive apps

Notifications You must be signed in to change notification settings

dasdeck/state-stack

Repository files navigation

state-stack

circleci-status npm version Coverage Status npm JavaScript Style Guide

bitHound Dependencies bitHound Dev Dependencies bitHound Overall Score bitHound Code

simple and fast undo/redo function for your web applications

the state-stack offers a simple undo/redo interface to store and restore application states. This undo/redo method has its limits, but does suffice for simple applications and is very easy to implement. Since this idea has been developed around Vue2 and Vuex there are specific packages for even simpler usage with Vue2

install

npm i state-stack --save

docs

api & more

quick example

import StateStack from 'state-stack'

let history = new StateStack();

let myState = {value:'initial value'};

//tell the history wich state to manage
history.setState(myState);

history.on('changed',()=>{
    //replace your original state after undo/redo
    myState = history.getState();
});



history.startTransaction('change value'); // crates an undo point

myState.value = "new value";

history.undo();

// myState.value === 'initial value'

About

simple state-stack (undo/redo history) for fast undo redo for small reactive apps

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published