npm.io
0.0.4 • Published 6 years ago

@fa-repo/undo-redo

Licence
mit
Version
0.0.4
Deps
0
Size
31 kB
Vulns
0
Weekly
0
Stars
2

@fa-repo/undo-redo

A javascript package for handling basic undo/redo functionality

NPM

Install

npm install --save @fa-repo/undo-redo

Basic usage

import UndoRedo from '@fa-repo/undo-redo';
import arrayMove from 'array-move';

let items = ['apple', 'pear', 'mango'];

const undoRedo = new UndoRedo();

const moveItem = (from, to) => {
  undoRedo.add({
    do: () => arrayMove(items, from, to),
    undo:() => arrayMove(items, to, from),
  })
}

const undoChanges = () => {
  undoRedo.undo();
}

const redoChanges = () => {
  undoRedo.redo();
}

Docs / examples

Discover api and use cases here.

License

mit @fa-repo