leva
leva copied to clipboard
Serialization & persistance
Users should be able to persist changes or to serialize and saved them
@emmelleppi started doing work for this in use-tweaks
I think this one will be way easier since we can just serialize, unserialize the whole store. Thoughts? @dbismut
Should be trivial indeed! The only thing is for the button input: I'm not sure you can serialize/unserialize functions?
Those are declared in the code though, we are only going to save the actual data, right?
Oh yes sure, in that case that's a two liner. We should also save the settings (like min/max/step) right? Or just the values?
How would we trigger serialization?
Probably just the values, assuming settings don't change ( or using schema as a key for localstorage? ). Thinking about it, there are some problems where:
- user serializes state
- changes tweaks settings/dirs
- now state and tweaks don't work with eachother ( this happens with theatre js too )
We can forget about it for now 🤷♂️
RE: Probably make it configurable via the useTwixSettings
hook we thought about ( #13 )
Is there a way to save the configuration and load it again? How would you do it?
Would be great if we could get this functionality added so we can persist settings in localstorage and load the initial settings from a saved state.
We currently use levaStore.set(query)
but it causes double renders since components mount with the default settings.