history-adapter

A "history adapter" for managing undoable (and redoable) state changes.

MIT License

Downloads
25
Stars
2
Committers
3

Bot releases are hidden (Show)

history-adapter - v1.2.0 - Pausing history Latest Release

Published by EskiMojo14 6 months ago

This minor release:

  • adds the ability to pause history being recorded
  • switches default createSelector instance to createDraftSafeSelector

Pausing history

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.

history-adapter - v1.1.0 - selectHistoryState

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

history-adapter - v1.0.0 - Initial release!

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