Skip to content
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

Could we invoke mutation directly in action? #277

Open
Dimitri-WEI-Lingfeng opened this issue Jun 12, 2020 · 3 comments
Open

Could we invoke mutation directly in action? #277

Dimitri-WEI-Lingfeng opened this issue Jun 12, 2020 · 3 comments

Comments

@Dimitri-WEI-Lingfeng
Copy link

Code assumed:

@Mutation
increment(){
  this.count++
}
@Action
act(){
  this.increment()  // instead of this.context.commit('increment')
}

I've seen this usage in "vue typescript admin template" and many other examples.
Is that legal? But why it is not mentioned in the doc. I think it'is more convinient than commitment.

@samtstern
Copy link

From what I have seen it does not work, this was very confusing to me. We should at least update the docs to show how this needs to be done as not everyone wants to use @MutationAction

@bangjelkoski
Copy link

This should be possible if you are using Dynamic Modules.

@Pacheco95
Copy link

@bangjelkoski I have used this approach in static modules without any issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants