Releases: EskiMojo14/history-adapter
v2.1.1
v2.1.0
This minor release:
- adds the ability for custom adapter creators to constrain the data type
- adds a
withRedux
enhancer for custom adapter creators
v2.0.0 - A rethink
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 changescreatePatchHistoryAdapter
available for previous behaviour- similarly,
HistoryState
type no longer uses patches, whereasPatchHistoryState
does
- Second argument for
undoable
can no longer beisUndoable
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
This minor release:
- adds the ability to pause history being recorded
- switches default
createSelector
instance tocreateDraftSafeSelector
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
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!
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