Comments (2)
So the goal of the __internal_mutator__
and __internal_getter__
is to act as a parent mutator
or getter
for the state
when strict is set to false.
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 mutation
and getter
defined. I think this is unecessary. And there's really no difference in functionality between the two mutations and getters.
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 ]
}
}
from vuex-class-component.
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.
from vuex-class-component.
Related Issues (20)
- Mutation requires object reference to change
- Cannot write independent tests because of module cache HOT 1
- Vuex 5 support and breaking changes
- TypeError: commit is not a function HOT 1
- Change the namespace later to create an abstract store
- [Bug] Actions force you to be async HOT 2
- ProxyWatchers small declaration issue
- watch, $subscribe and $subscribeAction all return void instead of the unsubscribe function HOT 1
- [BUG] npm package Version 2.3.2 still has pr #64 related issues. HOT 2
- Has no exported createModule
- [BUG]Mutation in Action doesn't work sometimes. HOT 2
- Calling getter in mutation HOT 1
- [Feature] ApiValue and ApiAction for fetching remote resources into store HOT 1
- Built files in "/dist" not updated? HOT 1
- [Bug] Store broken in 2.3.4 HOT 3
- [Bug] SSR data not saved in store when using nuxt fetch hook HOT 3
- Feature Request: A Bind decorator for class components
- Example on how to use with Nuxt HOT 3
- Access plugin on Action HOT 7
- Vue3 compatible HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vuex-class-component.