pmndrs / leva

🌋 React-first components GUI
https://leva.pmnd.rs
MIT License
5k stars 198 forks source link

Serialization & persistance #12

Open gsimone opened 3 years ago

gsimone commented 3 years ago

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

dbismut commented 3 years ago

Should be trivial indeed! The only thing is for the button input: I'm not sure you can serialize/unserialize functions?

gsimone commented 3 years ago

Those are declared in the code though, we are only going to save the actual data, right?

dbismut commented 3 years ago

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?

gsimone commented 3 years ago

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:

We can forget about it for now 🤷‍♂️

RE: Probably make it configurable via the useTwixSettings hook we thought about ( #13 )

CptCompiler commented 3 years ago

Is there a way to save the configuration and load it again? How would you do it?

ffdead commented 2 years ago

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.