-
Notifications
You must be signed in to change notification settings - Fork 21
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
[Feature] Add field name to internal mutations #51
Comments
So the goal of the Adding the field name would defeat that purpose. Eg say you have a store like this class UserStore extends createModule({ strict: false }){
firstname = "John";
lastname = "Doe"
} One way to generate the actual vuex store would something like this. const userStore = {
state: {
firstname: "John",
lastname: "Doe"
},
mutations: {
__generated_mutator_setFirstName__: ( state, payload ) =>state.firstname = payload,
__generated_mutator_setLastName__: ( state, payload ) =>state.lastname = payload,
},
getters: {
__generated_getter_getFirstName__: ( state ) => state.firstname,
__generated_getter_getLastName__: ( state ) => state.lastname,
},
} My issue with this is that for each state, there is an additional This is where the internal_mutator comes into play, so you have something like this. const userStore = {
state: {
firstname: "John",
lastname: "Doe"
},
mutations: {
__userStore_internal_mutator__: (state, { field, payload }) => state[ field ] = payload,
},
getters: {
__userStore_internal_getter__: (state, field) => state[ field ]
}
} |
Yes exactly. So the only benefit of adding the field name would be a cleaner devtools experience. But from what I understand at really no cost - unless it's difficult to implement of course. |
When one uses the strict=false method all the mutations look like this in the Vue dev tools:
MyStoreName/__mystorename_internal_mutator__
I think having the field name in there would help a lot with debugging with Vue Dev Tools.
The text was updated successfully, but these errors were encountered: