Skip to content

v1.1.0 - selectHistoryState

Compare
Choose a tag to compare
@EskiMojo14 EskiMojo14 released this 12 Mar 00:42
· 135 commits to main since this release

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