Skip to content

Add ability to access namespaced getters with dot notation #1258

Open
@jmcooper

Description

@jmcooper

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions