npm zundo 2.0.0-beta.15
v2.0.0-beta.15 - Init states

latest releases: 2.3.0, 2.2.0, 2.1.0...
2 years ago

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 and futureStates 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

Don't miss a new zundo release

NewReleases is sending notifications on new releases.