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