Can you tell me how to call a mutation from a mutation in a vuex module?
See original GitHub issueAs a example:
import {
Module,
VuexModule,
Mutation,
Action,
} from 'vuex-module-decorators'
import Vuex from 'vuex';
import Vue from 'vue'
Vue.use(Vuex);
@Module({
name: 'Block',
namespaced: true,
dynamic: true,
store: new Vuex.Store({}),
})
export default class Block extends VuexModule {
@Mutation
oneMutation( payload ) {
let { var1, var2 } = payload;
let var3 = this.otherMutation(var1); // <-- that!
this.stateVariable = var3 + var2;
}
@Mutation
otherMutation( var ) {
// ... some calculations
}
}
the fact is that I need methods available both from the mutation and from other components.
Thank you!
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Mutations | Vuex
To invoke a mutation handler, you need to call store.commit with its type: ... Whether to use constants is largely a preference -...
Read more >Can I call commit from one of mutations in Vuex store
Yes, it is possible to have a commit from another mutation with no side-effects. But debugging an incorrect state change when we have...
Read more >Please add an ability to call mutation from another ... - GitHub
If you call a mutations in other mutations, they cannot be separated in devtools and it decrease trackability.
Read more >Call a Root Vuex Mutation or Action from within a Module in ...
You go to LoginModule, you see there we are setting the rootState to second parameter of the module type. To fix it, go...
Read more >Vuex Tutorial #6 - Mutations - YouTube
Hey all, in this Vuex tutorial I'll show you how to mutate data on the store. Mutations allow us to track when and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I might be wrong but i think mutation should only change the state and not do other stuff. If you want to do few mutations at once maybe you should create an action instead?
Okay, thanks.