Skip to content

Releases: EskiMojo14/history-adapter

v2.1.1

17 Jun 10:27
Compare
Choose a tag to compare

This patch release removes usage of reselect and deprecates the createSelector option for getSelectors.
This is because the selectors have no need of memoization.

v2.1.0

01 Jun 14:09
Compare
Choose a tag to compare

This minor release:

v2.0.0 - A rethink

30 May 17:02
Compare
Choose a tag to compare

Up to this point, the history adapter has always tracked changes with JSON Patches, a data format that looks something like the below:

{
  undo: [
    {
      op: "replace",
      path: ["present", "value"],
      value: 0,
    },
  ],
  redo: [
    {
      op: "replace",
      path: ["present", "value"],
      value: 1,
    },
  ],
}

However, if your changes are more complex than your state shape, these can end up being pretty large.

Packages like redux undo instead store the entire version of state, and flip back and forth as needed.

In 2.0, createHistoryAdapter will now use this approach, and a createPatchHistoryAdapter version is available to use the previous behaviour.

Breaking changes

  • createHistoryAdapter now uses entire copies of state, rather than patches of changes
    • createPatchHistoryAdapter available for previous behaviour
    • similarly, HistoryState type no longer uses patches, whereas PatchHistoryState does
  • Second argument for undoable can no longer be isUndoable function - needs to be config object

Other changes

  • Build is no longer minified, allowing for better minification in the user's bundler

v1.2.0 - Pausing history

20 Apr 23:31
Compare
Choose a tag to compare

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.

v1.1.0 - selectHistoryState

12 Mar 00:42
Compare
Choose a tag to compare

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

v1.0.0 - Initial release!

22 Jan 14:45
Compare
Choose a tag to compare

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