A "history adapter" for managing undoable (and redoable) state changes.
MIT License
Bot releases are visible (Hide)
This minor release:
createSelector
instance to createDraftSafeSelector
The history state shape now has a paused
property which indicates whether changes should be recorded or not. It does not prevent state from being updated, it just prevents those updates from being recorded into history. As a result they cannot be undone or redone.
Use adapter.pause(state)
to set the paused
property to true
, and adapter.resume(state)
to set it back to false
.
Published by EskiMojo14 7 months ago
This minor release adds a selectHistoryState
config option to undoable
and undoableReducer
, allowing them to deal with nested history state. For example:
interface RootState {
books: HistoryState<Array<Book>>;
}
const addBook = booksAdapter.undoable(
(books, book: Book) => {
books.push(book);
},
{
selectHistoryState: (rootState: RootState) => rootState.books,
},
);
const withBook = addBook({ books: booksAdapter.getInitialState([]) }, book);
Published by EskiMojo14 9 months ago
This library contains a number of useful methods for managing an undoable state, where changes are stored as JSON patches and applied by Immer.
Full Changelog: https://github.com/EskiMojo14/history-adapter/commits/v1.0.0