I've been using the vuex-persistedstate
module to handle state management and store it in localStorage
. However, whenever there's an update to the data, the app freezes due to the amount of state that needs to be saved.
To address this issue, I'm attempting to implement a promise that allows for business calculations to take place while the string is being generated. Once the string is prepared, it should then be stored in localStorage
.
This is the approach I'm currently testing:
const buildLocalStorageString = async (state) => {
return await JSON.stringify(state);
}
export default new Vuex.Store({
state: { etc, etc, etc },
plugins: [createPersistedState({
key: 'myApp',
setState (key, state, storage) {
buildLocalStorageString(state).then(string => {
storage.setItem(key, string)
})
}
})],
})
Despite these efforts, the problem remains unresolved. There's still a noticeable lag whenever the app undergoes updates.