UndoService

I recently published a generic undo/redo service on NuGet and GitHub. It is based on the momento pattern and uses delegate methods to access state.

The main benefit of this is how simple it is to use. To use it, you pass the type that is used to store state and the methods to get and set the state (most likely in wrappers to match the delegate signature). Once that is in place, you just invoke RecordState() to get the state and store it in the Undo stack, along with Undo(), Redo() and Clear() methods as appropriate.

The data structure it uses depends on whether you set a limit on the number of states that it stores. If a limit is set, it uses a dropout stack. Without a limit, it uses a standard stack.

There is no nesting or grouping of undoable actions. It is possible that I’ll add such a feature in the future but I have no specific plans to do so.

https://github.com/peterdongan/UndoService

https://www.nuget.org/packages/UndoService/

Leave a Reply

Your email address will not be published. Required fields are marked *