Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement: Make store hydrate to localstorage if needed #108

Open
eznix86 opened this issue Mar 29, 2024 · 2 comments
Open

Improvement: Make store hydrate to localstorage if needed #108

eznix86 opened this issue Mar 29, 2024 · 2 comments

Comments

@eznix86
Copy link
Contributor

eznix86 commented Mar 29, 2024

  • Currently if we need to store elements into store and persist them, we have to do it in 2 steps.
  • Which is storing the data to local storage then retrieve the data.

Instead we can do,

  • On mutation of the store we save to local storage (can be replaced with dixiejs because local storage is synchronous).
  • On App boot we hydrate the data in to the state.

Example here:
https://www.mikestreety.co.uk/blog/vue-js-using-localstorage-with-the-vuex-store/

app <-> state <-> update storage on mutation / fetch state on boot.

Benefits:

  • Reduce checks,
  • storage is coupled/bounded to the local storage,
  • Less code to maintain.
@flawiddsouza
Copy link
Owner

Sounds like a good improvement. But we don't need to persist everything in the store to the localStorage. If we can limit it to the items that are used for configuring the application, that would be better. I've been planning to move away from localStorage but I never got the time to do it. This would mean we'd have to migrate the existing user configuration as well, as we can't have users suddenly losing their existing settings because there's a new update to the settings system.

@eznix86
Copy link
Contributor Author

eznix86 commented Mar 29, 2024

I agree, but I think we can prevent a breaking change if we do it meticulously.

Just proposing to make it simpler because when coding on the previous PR, It seems weird to always update the storage then change the store.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants