Releases: charkour/zundo
v2.0.0-beta.22 - Reduce size by moving internals
v2.0.0-beta.21 - isTracking Flag
852 B --> 839 B
Breaking Change
- trackingStatus: 'tracking' | 'paused'
+ isTracking: boolean
- trackingStatus === 'tracking'
+ isTracking === true
- trackingStatus === 'paused'
+ isTracking === false
Stop and start history
isTracking: boolean
isTracking
: a stateful flag in the temporal
store that indicates whether the temporal
store is tracking state changes or not. Possible values are true
or false
. To programmatically pause and resume tracking, use pause()
and resume()
explained below.
Pause tracking of history
pause: () => void
pause
: call function to pause tracking state changes. This will prevent new states from being stored in history within the temporal store. Sets isTracking
to false
.
Resume tracking of history
resume: () => void
resume
: call function to resume tracking state changes. This will allow new states to be stored in history within the temporal store. Sets isTracking
to true
.
What's Changed
Full Changelog: v2.0.0-beta.20...v2.0.0-beta.21
v2.0.0-beta.20 - Only copy when necessary
850 B --> 852 B
What's Changed
- Copy past and future states only if necessary by @KevinMusgrave in #112
New Contributors
- @KevinMusgrave made their first contribution in #112
Full Changelog: v2.0.0-beta.19...v2.0.0-beta.20
v2.0.0-beta.19 - Smaller Bundle Size by 0.82%
v2.0.0-beta.18 - Improve _handleSet, shave 20 bytes (2.3% smaller)
877 B --> 857 B (Shave 20 bytes)
What's Changed
- remove objects. save 19 bytes by @charkour in #96
- simplify types, refactor _handleSet heuristics by @charkour in #97
- move immer to root to fix broken examples from 8608dd9 by @charkour in #99
- simplify repo by @charkour in #100
- update tsconfig for examples by @charkour in #102
Full Changelog: v2.0.0-beta.17...v2.0.0-beta.18
v2.0.0-beta.17 - Drop Node 14, Smaller Bundle by 1.2%
v2.0.0-beta.16 - Temporal Middleware
New Feature!
Wrap temporal store from @SugarF0x
wrapTemporal?: (storeInitializer: StateCreator<TemporalStateWithInternals<TState>, [StoreMutatorIdentifier, unknown][], []>) => StateCreator<TemporalStateWithInternals<TState>, [StoreMutatorIdentifier, unknown][], [StoreMutatorIdentifier, unknown][]>
You can wrap the temporal store with your own middleware. This is useful if you want to add additional functionality to the temporal store. For example, you can add persist
middleware to the temporal store to persist the past and future states to local storage.
Note: The
temporal
middleware can be added to thetemporal
store. This way, you could track the history of the history. π€―
import { persist } from 'zustand/middleware'
const withTemporal = temporal<MyState>(
(set) => ({ ... }),
{
wrapTemporal: (storeInitializer) => persist(storeInitializer, { name: 'temporal-persist' }),
},
);
Size 865 B --> 888 B (increase 23 B)
What's Changed
Full Changelog: v2.0.0-beta.15...v2.0.0-beta.16
v2.0.0-beta.15 - Init states
New feature!
Initialize temporal store with past and future states
pastStates?: Partial<PartialTState>[]
futureStates?: Partial<PartialTState>[]
You can initialize the temporal store with past and future states. This is useful when you want to load a previous state from a database or initialize the store with a default state. By default, the temporal store is initialized with an empty array of past and future states.
Note: The
pastStates
andfutureStates
do not respect the limit set in the options. If you want to limit the number of past and future states, you must do so manually prior to initializing the store.
const withTemporal = temporal<MyState>(
(set) => ({ ... }),
{
pastStates: [{ field1: 'value1' }, { field1: 'value2' }],
futureStates: [{ field1: 'value3' }, { field1: 'value4' }],
},
);
Related #75
847 B --> 865 B (increase 18 bytes)
What's Changed
Full Changelog: v2.0.0-beta.14...v2.0.0-beta.15
v2.0.0-beta.14 - 2.4% smaller
Reduce package size by 21 bytes.
868 B --> 847 B
What's Changed
Full Changelog: v2.0.0-beta.13...v2.0.0-beta.14
v2.0.0-beta.13 - 7.3% smaller bundle
7.3% smaller by shaving 69 bytes. Add better React tests
937 bytes --> 868 bytes
Breaking change
This a potentially breaking change for those who rely on internal properties.
// Before
myStore.temporal.getState().__interal.onSave
// After
myStore.temporal.getState().__onSave
// Before
myStore.temporal.getState().__interal.handleuserSet
// After
myStore.temporal.getState().__handleUserSet
What's Changed
Full Changelog: v2.0.0-beta.12...v2.0.0-beta.13