-
-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot use $store.dispatch on a named static module #354
Comments
@ArielPrevu3D Can you please provide a code example? Because I am not exactly sure what you want to achieve here. |
This is my static Vuex store module. // test.store.ts
import { Action, Module, VuexModule } from "vuex-module-decorators";
@Module({name: 'testStore', namespaced: false})
class TestStore extends VuexModule {
testStateField: boolean = true
@Action
dood() {
console.log("DOOD")
}
}
export default TestStore // store.ts
import Vue from "vue";
import Vuex from "vuex";
import TestStore from "./stores/test.store";
Vue.use(Vuex);
const store = new Vuex.Store({
modules: {
testStore: TestStore
}
});
export default store; // In some javascript component....
this.$store.dispatch("dood") Then it gives me this error:
I gave a name to the static store so I could use both I ended up making the store dynamic to get this to work. There isn't really a disadvantage in making the store dynamic, so I guess it's a proper workaround. |
@ArielPrevu3D , Can i know the reason why you had to give a name and namespace as "false" I will try to raise PR with a change to check based on name and namespace , in the mean time , if possible remove name and check . |
Hi,
I need my static module to have a name in order to be able to use
getModule
on it. However, doing so prevents my legacy code from using$store.dispatch
becausegetModule
is used internally without a store as a second argument. The store cannot be passed to theModule
decorator of the module since it is static.The text was updated successfully, but these errors were encountered: