@stateloom/history
v1.0.0-alpha.0
Published
Snapshot-based undo/redo middleware for StateLoom stores.
Downloads
51
Readme
@stateloom/history
Snapshot-based undo/redo middleware for StateLoom stores.
Install
pnpm add @stateloom/historyQuick Start
import { history } from '@stateloom/history';
import { createStore } from '@stateloom/store';
const h = history<{ count: number }>({ maxDepth: 50 });
const store = createStore(
(set) => ({
count: 0,
inc: () => set((s) => ({ count: s.count + 1 })),
}),
{ middleware: [h] },
);
store.getState().inc(); // count -> 1
h.undo(); // count -> 0
h.redo(); // count -> 1
h.canUndo.get(); // trueExports
| Export | Description |
| ------------------- | --------------------------------------------------------------------- |
| history(options?) | Create undo/redo middleware with reactive canUndo/canRedo signals |
Documentation
Full documentation with API reference, patterns, and integration examples: docs/api/history
License
MIT
