Skip to content

Latest commit

 

History

History
46 lines (31 loc) · 788 Bytes

README.md

File metadata and controls

46 lines (31 loc) · 788 Bytes

Undo/Redo

A javascript package for handling undo/redo functionality.

Read the docs

NPM

Install

yarn add @fa-repo/undo-redo --dev

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();
}

License

MIT