-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Vuex 2.0 module's actions and getters namespacing #335
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
Comments
I guess it's something like this:
where |
@Namek honestly that convention doesn't seem too elegant since actions, getters and mutations need to be namespaced. It would be good to have in the documentation some best practices. |
Well, then I don't know what kind of "namespacing" the docs refer to. I got this from some older examples. |
Namespacing in the doc means adding prefix or suffix to getters, actions and mutations names to avoid name conflict. |
@ktsn Do you have some sample code with prefixed actions, getters, etc.? I want to standardize my application's prefixes with something like "module:action", but I have no clue how to make it happen given that I just cant declare an action with a semicolon in the name. |
Like this? https://jsfiddle.net/bjahdbx5/1/ |
Thank you for the code. That is exactly the result I'm trying to achieve. But it does seem that it would get extremely verbose adding this code to all actions, getters and mutations per module. Is there any way to automate the generation of the prefix in the module.js file? |
Do you mean that you do not want to write Vuex does not concern about how to define getters, actions and mutations names since it is userland issue. |
Thanks for the help @ktsn. Your code helped me to create a helper utility to namespace getters, actions and mutations in Vuex 2.0 modules. This functionality really should be included in Vuex itself. Large application need this, and leaving this for the user to deal with only adds a huge amount of unnecessary boilerplate code. |
I think it should not be included into Vuex because it can be solved by external library and using constants is optional. |
The doc is updated with the description and example about namespace. |
Thanks @ktsn. Since namespacing is a must in large size applications, here is how we are doing it with the least amount of boilerplate code:
The above automatically namespaces getters, actions and mutations using the |
Mark~You guys are so cool! |
@jxlarrea - if I understand what you shared correctly, when using your |
@morficus I'm wondering the same thing. If you leave the module namespacing set to true, then it will double namespace when using the I'm still testing it out but I think this is the way to go |
The documentation is quite vague regarding namespacing actions and getters from a module. Can someone please elaborate on how to achieve this?
The text was updated successfully, but these errors were encountered: