beekai-oss / little-state-machine

📠 React custom hook for persist state management
https://lrz5wloklm.csb.app/
MIT License
1.47k stars 53 forks source link

fix: persist option none is not working #137

Closed snax4a closed 2 years ago

snax4a commented 2 years ago

I have fixed persist options. Before that, the 'none' option was not working. Now, when 'none' option is passed the state is not being saved to any store in action handler.

I have introduced PersistOption enum for better DX but string literals are also available for backward compatibility.

export enum PersistOption {
  None = 'none',
  OnAction = 'onAction',
  BeforeUnload = 'beforeUnload',
}

CleanShot 2022-09-16 at 14 45 23

I have also updated the store factory options type so it's less hacky.

Locally everything seems to work correctly