nuxt-community / universal-storage-module

Universal Storage Utilities for Nuxt 2
MIT License
276 stars 15 forks source link

$storage.state not reactive #155

Open atinux opened 3 years ago

atinux commented 3 years ago

I tried a demonstration using CodeSandBox with disabling Vuex.

https://codesandbox.io/s/flamboyant-browser-cpucn?file=/pages/index.vue

I actually have to call $forceUpdate() in the component, It's weird since we use Vue.set(), maybe we should define the state using Vue.observable ?

atinux commented 3 years ago

Also, the token in the localStorage and cookie is undefinedtoken because I specific localStorage: true:

Screenshot 2020-11-27 at 13 43 35

pi0 commented 3 years ago

I can confirm the bug with store disabled. We indeed need to use observable (and probably also document better about initialState)

pi0 commented 3 years ago

Auth module uses same implementation which is probably affected: https://github.com/nuxt-community/auth-module/blob/83adce54190f097a965a33787f96faf9eb479f97/src/core/storage.ts#L116

selimdev00 commented 2 years ago

Also, the token in the localStorage and cookie is undefinedtoken because I specific localStorage: true:

Screenshot 2020-11-27 at 13 43 35

I guess you need to specify prefix in options like this:

localStorage: {
  prefix: 'some-prefix-',
},