My component does not update the loaded property when Store.loaded changes:
Component
import { Vue } from 'vue-property-decorator'
import Component from 'nuxt-class-component'
import { Store } from '../repositories'
@Component
export default class Layout extends Vue {
loaded = Store.loaded
}
Store
class Root {
loaded = false
}
export let Store = new Root()
export default Store
In your example
Store
is just plain function (class), without any reactivity (no Vue watchers attached forStore.loaded
field).Only properties inside component's
data
are reactive. If you want reactive single store outside of vue components (better for big frontend applications), you should use VuexSimple example will be:
App.vue:
components/ChildComponent.vue:
And reactive Vuex store:
store/index.js:
You can find full source of this example on GitHub.