New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

patched-undo-peasy

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

patched-undo-peasy

undo/redo for easy peasy

  • 0.1.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Undo/Redo support for easy peasy.

patched-undo-peasy depends on an easy peasy fork. (but modifying undo-peasy to depend on stock easy-peasy should be straightforward.)

Usage

  1. Attach undoRedoMiddleWare in createStore.
    const store = createStore(appModel, {
      middleware: [undoRedo()],
    });
    
  2. If using typescript, the root application model should extend WithUndo. WithUndo will add types for undo actions and undo history to your root model.
      interface Model extends WithUndo {
        count: number;
        increment: Action<Model>;
      }
    
  3. Wrap the root application instance in undoable. undoable will add types for undo actions and undo history to your root model.
    const appModel: Model = undoable({
      count: 0,
      increment: action((state) => {
        state.count++;
      }),
    });
    
  4. Profit
    const undoAction = useStoreActions((actions) => actions.undoUndo);
    

Supported Actions

  • undoUndo - restore state to the most recently saved version.
  • undoRedo - restore state to the most recently undone version.
  • undoSave - save current application state to undo history. undoSave is generated automatically by the middleware, but in rare cases it's useful to save manually.
  • undoReset - erases saved undo/redo history and saves the current state.

Configuration

The undoRedo() middleware function accepts an optional configuration object.

  • noSaveActions - a function that tells undoRedo to not save certain actions to undo/redo history.
  • noSaveKeys - a function tthat tells undoRedo not to save certain keys inside the state model to undo/redo history. e.g. view state in the model.

Keywords

FAQs

Package last updated on 12 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc