#makePersisted createStore
5 messages · Page 1 of 1 (latest)
makePersisted(createStore(...))
also you can write your own
getting the initial value is just JSON.parse(localstorage.getItem("my-key"))
and syncing changes can be done by intercepting all writes
const wrappedSetAccount: typeof setAccount = (...args: any[]) => {
setAccount(...args)
const state = unwrap(account)
localstorage.setItem("my-key", JSON.stringify(state))
}
then you can add validation logic
in case you want to make sure that the state read from storage has the shape you expect
powerful but undocumented feature: stores are composable https://playground.solidjs.com/anonymous/823cdab6-ba05-432f-a26e-c8aa3a1ce187
Quickly discover what the solid compiler will generate from your JSX template