Open tkaizer98 opened 5 years ago
Can you provide more context? How does your store file look like? Providing more information about these modules would also be helpful.
Same for me, when I'm in a module I'm not able to call an action from an action in another module.
this.context.dispatch('authentication/login', null, { root: true })
The authentication module looks like:
@Module({ name: 'authentication', namespaced: true })
export default class AuthenticationModule extends VuexModule {
@Action
public async login(): Promise<void> {
return new Promise((resolve) => {
console.log('You\'re logged in.')
resolve()
})
}
}
The error is the same as @tkaizer98 mentioned.
I encountered the same problem. When I combined 'vuex-class' with 'vuex-module-decorators', the same error occurred
here is the outline of my code: store/module/user : views/home.vue:
I encountered the same problem.
The workaround is removing the name
attribute in @Module
decorator and it will work without any errors.
@Module({ namespaced: true })
I use vuex-module-decorators
with vuex-class
and it is working fine without errors.
@preetishhs i got this problem instead when remove name
in @Module
😄
@duckytutu Oh. I didn't get any such errors. Take a look at this Repo. I created this project just last week for an article.
https://gitlab.com/preetishhs/ts-vue-sample
https://github.com/preetishhs/Vue-typescript-example
I use vuex-module-decorators
. I used to get the same error but when I removed name
it started to work fine.
Hey @preetishhs , thanks for sharing your demo - I think it might be set to private, I'm getting a 404 error.
@MitchellFry Sorry, I had moved it to Github. Please check this https://github.com/preetishhs/Vue-typescript-example
I can also confirm this bug (actually I came here by googling the error message). I have two modules with a name attribute in @Module, and I can not call actions, same stacktrace (but mutations work fine).
Removing the name attribute fixed this.
By removing the property name from module decorator also "solved" to me
Remove the name
property works fine with mine either. (Using Nuxt by the way.)
But WHY it works ???
I'm also using vuex-class
and Removing name
worked for me also.
please see notice That works only in dynamic modules.
,
so you should register modules likes thit.
@Module({dynamic: true, store, name: 'mm'})
even so, you can't use it directly.
we need to load it before we use it.
import { getModule } from 'vuex-module-decorators'
import YourModules from 'xxx'
import store from '@/store'
now,we should do it in one of two ways: 1,
// Use its related properties and methods directly
getModule (YourModules )
store.dispatch('name/xxxx')
2,
const yourModule = getModule (YourModules )
yourModule.xxxx()
I am using two namespaced modules. In one module I have an action in which I am trying to commit a mutation from the other module. I am getting this error:
here is the outline of my code:
socketStore.ts
I call this action in Home.vue with
It seems to work when I call the same function (createSocket) as a mutation. I cannot do this however because I need to call other mutations inside of it.