Zundo Versions Save

🍜 undo/redo middleware for zustand. <700 bytes

v2.0.0-beta.20

11 months ago

850 B --> 852 B

What's Changed

New Contributors

Full Changelog: https://github.com/charkour/zundo/compare/v2.0.0-beta.19...v2.0.0-beta.20

v2.0.0-beta.19

11 months ago

857 B --> 850 B

What's Changed

Full Changelog: https://github.com/charkour/zundo/compare/v2.0.0-beta.18...v2.0.0-beta.19

v2.0.0-beta.18

11 months ago

877 B --> 857 B (Shave 20 bytes)

What's Changed

Full Changelog: https://github.com/charkour/zundo/compare/v2.0.0-beta.17...v2.0.0-beta.18

v2.0.0-beta.17

11 months ago

888 B --> 877 B (save 11 bytes)

Breaking

  • Node 14 is no longer supported
  • The internal types have been renamed

What's Changed

Full Changelog: https://github.com/charkour/zundo/compare/v2.0.0-beta.16...v2.0.0-beta.17

v2.0.0-beta.16

1 year ago

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 the temporal 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: https://github.com/charkour/zundo/compare/v2.0.0-beta.15...v2.0.0-beta.16

v2.0.0-beta.15

1 year 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 https://github.com/charkour/zundo/issues/75

847 B --> 865 B (increase 18 bytes)

What's Changed

Full Changelog: https://github.com/charkour/zundo/compare/v2.0.0-beta.14...v2.0.0-beta.15

v2.0.0-beta.14

1 year ago

Reduce package size by 21 bytes. 868 B --> 847 B

What's Changed

Full Changelog: https://github.com/charkour/zundo/compare/v2.0.0-beta.13...v2.0.0-beta.14

v2.0.0-beta.13

1 year ago

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: https://github.com/charkour/zundo/compare/v2.0.0-beta.12...v2.0.0-beta.13

v2.0.0-beta.12

1 year ago

962 B --> 937 B (25 bytes)

What's Changed

Full Changelog: https://github.com/charkour/zundo/compare/v2.0.0-beta.11...v2.0.0-beta.12

v2.0.0-beta.11

1 year ago