-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Middleware processing between actions and mutation. #958
Comments
It is possible to make a plugin to do this. See https://vuex.vuejs.org/en/plugins.html. They are like redux middlewares, which seems to be what you are looking for See the top:
You can check for the type of mutation (such as |
@lmiller1990 acutally plugin run after the commit, so that doesn't allow what @xuchenchenBoy is asking for. |
Not sure if I understand this correctly, might be related to #929? |
It seems to be, yes |
@lmiller1990 Thanks, but i want to deal with mutation before it is executed. |
@deini Yes, you are right. |
Does Vuex have some similar mechanism like redux middleware so that I can manipulate payload of mutations before they're committed? |
I don't think you can achieve that using Vuex out of the box. That's the same question @xuchenchenBoy asks above. |
@blooddrunk See #929. |
What problem does this feature solve?
When executing the request action, the unified processing of the mutation method that needs to be performed is performed. This reduces a lot of repetitive code and is more concise and elegant.
What does the proposed API look like?
This is actionMiddleware:
The text was updated successfully, but these errors were encountered: