Closed SaphuA closed 5 years ago
It seems like the options are used of the last extracted module, or something like that...
export class StoreA extends createModule({ namespaced: "StoreA", strict: true }) { }
export class StoreB extends createModule({ namespaced: "StoreB", strict: true }) { }
console.log(extractVuexModule(StoreA));
console.log(extractVuexModule(StoreB));
export class StoreC extends createModule({ namespaced: "StoreC", strict: true }) { }
console.log(extractVuexModule(StoreA));
console.log(extractVuexModule(StoreB));
console.log(extractVuexModule(StoreC));
prints
{StoreB: {…}}
{StoreB: {…}}
{StoreB: {…}}
{StoreB: {…}}
{StoreC: {…}}
Seems very likely this has something to do because you're using the prototype here, which is always VuexModule
:
Mind sharing a sample project so I can replicate your issue.
Thanks
Here you go. I've added some console.log's to src/store.ts
yarn install
yarn serve
This issue has been resolved in the latest version
Looks ok! I'll do some more testing this week.
So when exactly should one use createModule
and when With
for providing options?
With is useful for extending already defined options.
Ideally you want to create a base configuration like so:
const VuexModule = createModule({
strict: false,
target: "nuxt",
enableLocalWatchers: true,
})
export class UserStore extends VuexModule.With({ namespaced: "user", strict: true }) {
}
Think of it as a 2 level inheritance for your module options.
Okay so I was a little too optimistic when I said your last commit fixed the namespace issues. It seems that only the namespace is used of the last store that is touched or used and therefore only this store is working (which was the only page I was testing at the time...).
I'll look into it and update this issue accordingly.