IssueRaiser

Add ability to access namespaced getters with dot notation

### What problem does this feature solve? When working with a namespaced module (e.g. a users module), you can access items on the user module's state like this: `this.$store.state.users.user` However, you can't access getters in the same way. This will return an error: `this.$store.getters.users.newUsers` Because `getters.users` is undefined. Instead you have to access it with bracket notation: `this.$store.getters['users/newUsers']` This is true even though, without modules, I can access getters with dot notation: `this.$store.getters.newUsers` Is there a reason why this isn't possible with getters? It would be nice if we could access namespaced getters in the same way we can with namespaced state. This current behavior seems inconsistent. ### What does the proposed API look like? Given a `users` namespaced module, add the ability to access getters with: `this.$store.getters.users.newUsers` <!-- generated by vue-issues. DO NOT REMOVE -->

Posted by jmcooper on May 5, 2018, 5:00 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.4,000 issues0 comments

github (Other)

Add ability to access namespaced getters with dot notation

jmcooperMay 5, 2018, 5:00 PM

### What problem does this feature solve? When working with a namespaced module (e.g. a users module), you can access items on the user module's state like this: `this.$store.state.users.user` However, you can't access getters in the same way. This will return an error: `this.$store.getters.users.newUsers` Because `getters.users` is undefined. Instead you have to access it with bracket notation: `this.$store.getters['users/newUsers']` This is true even though, without modules, I can access getters with dot notation: `this.$store.getters.newUsers` Is there a reason why this isn't possible with getters? It would be nice if we could access namespaced getters in the same way we can with namespaced state. This current behavior seems inconsistent. ### What does the proposed API look like? Given a `users` namespaced module, add the ability to access getters with: `this.$store.getters.users.newUsers` <!-- generated by vue-issues. DO NOT REMOVE -->

Comments (0)

No comments yet. Start the discussion.

Comment on this issue