We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I have several modules and want to commit chat module from one on actions of the user module.
chat
user
The problem:
i cannot use rootCommit. There is no Type error but at runtime this error occures:
Uncaught TypeError: rootCommit is undefined
This is my store:
const { store, rootActionContext, moduleActionContext, rootGetterContext, moduleGetterContext, } = createDirectStore({ state: { initialised: false, }, actions: { // Some actions }, mutations: { setInit(states) { states.initialised = true; }, }, modules: { chat: chatModule, user: userModule, session: sessionModule, }, }); export { store, rootActionContext, moduleActionContext, rootGetterContext, moduleGetterContext, };
My userModule:
export const userModule = defineModule({ namespaced: true as true, state: { userList: [], currentUserId: 0, } as UserStates, actions: userActions, mutations: userMutations, getters: userGetters, });
And this is a part of my userActions:
export const userActions = defineActions({ join(context) { const { rootCommit } = storeActionContext(context); Server.instance.send('something').subscribe((message)=>{ rootCommit.chat.addMessage(message); }) } } const storeActionContext = (context: any) => moduleActionContext(context, userModule);
The text was updated successfully, but these errors were encountered:
It should work. Maybe you could add some debug log:
join(context) { const directContext = storeActionContext(context); Server.instance.send('something').subscribe((message)=>{ console.log("directContext", directContext); directContext.rootCommit.chat.addMessage(message); }) }
Sorry, something went wrong.
No branches or pull requests
I have several modules and want to commit
chat
module from one on actions of theuser
module.The problem:
i cannot use rootCommit. There is no Type error but at runtime this error occures:
This is my store:
My userModule:
And this is a part of my userActions:
The text was updated successfully, but these errors were encountered: