Initialize State at app startup #9923
-
Where or how do I best initialize the state of my app at a startup? You'll see in the commented lines i need to set the apps Dark theme and primary color based on values in the app's state, which will eventually be reading the users saved settings so they can choose the app is light or dark theme. Should i be doing the commented lines in my store/index.js file? store/app/state.js
store/index.js
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The vuex store is a good place to put your user settings, except it does not persist data by default. So you'll loose all the settings the user changed after a refresh or a new session. You can either use something like vuex-persist( vuex plugin) or populate the store from localstorage ( use the quasar plugin, also you'll have to set the values in localstorage when the user changes settings). You can use a boot file with access to the store to run your |
Beta Was this translation helpful? Give feedback.
@JokerMartini
The vuex store is a good place to put your user settings, except it does not persist data by default. So you'll loose all the settings the user changed after a refresh or a new session. You can either use something like vuex-persist( vuex plugin) or populate the store from localstorage ( use the quasar plugin, also you'll have to set the values in localstorage when the user changes settings). You can use a boot file with access to the store to run your
init
.