DEV Community

Discussion on: Mapping for a Vuex beginner

 
napoleon039 profile image
Nihar Raote

I honestly haven't found an answer to it as well. It's like no one else wonders why we need to commit mutations in the store when we can dispatch an action for it. But since there's an example for mapping mutations in the component in the Vue documentation, there should be a reason.

Though I haven't seen this reasoning anywhere I think it's because an action is expected to do some asynchronous stuff along with committing mutations. So maybe a use case for committing mutations in the component is when actions do more than just commit mutations and we only need to commit a mutation and not the other stuff?

I'll try to see if there is an answer anywhere like Stackoverflow or ask on Twitter if I still can't find one.