I've been having a hard time avoiding "stuttering" in Vuex modules. It just seems that most of the time, the module's name is also what it contains.
For example, suppose a module that handles users. I name the module file user.js
export default {
state: {
users: []
},
// mutations and actions for reading, creating, updating users...
}
Then in my store's index.js
import user from 'user';
export default new Vuex.Store({
modules: {
user
}
});
When I want to get the list of users from a component I have to use:
this.$store.user.users
If I didn't use a module for the user list, I would just have had this.$store.users
, which is much more readable and elegant.
Any idea for a naming convention or design pattern that would avoid this stutter?