vuex icon indicating copy to clipboard operation
vuex copied to clipboard

WIP feat: access namespaced getters using the dot notation

Open hootlex opened this issue 5 years ago • 17 comments

Add's support for accessing namespaced getters using the dot notation, the same way we do for the state. For example: this.$store.getters.users.newUsers

Implements https://github.com/vuejs/vuex/issues/1258

Todo:

  • [x] Prefer root getter in case of same naming to not introduce braking changes - @hootlex
  • [x] Display warning if root getter has the same the name with a module. Similar to https://github.com/vuejs/vuex/issues/1363 - @hootlex
  • [x] Add complete test for namespaced getters - @simplesmiler
  • [x] Add tests for nested, namespaced modules - @simplesmiler
  • [ ] Docs - @hootlex

hootlex avatar Aug 03 '18 18:08 hootlex

cc @kazupon @ktsn @simplesmiler

hootlex avatar Aug 03 '18 18:08 hootlex

Would love to see this merged. It also closes #679. I implemented dotted getters in a patch I posted there before I knew about this!

chearon avatar Aug 22 '18 16:08 chearon

Any chance the slashed getters could be removed entirely in favor of just the nested structure? It would be a breaking change I guess, but it looks way nicer in the debugger to not have both of them. I've implemented it that way here.

chearon avatar Sep 06 '18 23:09 chearon

@chearon I don't think dropping the slashed getters is a good idea. It is a breaking change and I am sure many people prefer that syntax over the dot notation.

It's more likely that we introduce slashed state to provide a consistent API among Vuex assets.

hootlex avatar Sep 07 '18 08:09 hootlex

Any updates on this PR?

mittalyashu avatar Feb 23 '19 14:02 mittalyashu

@hootlex Would it be nice to discuss on dropping the slash getters for vue 3.0 in the rfc? This could avoid confusion later on such that the getters are more consistent with the others for namespacing.

pickfire avatar Feb 25 '19 01:02 pickfire

WRT removing slashed getters, as I mentioned in this issue, what'd be wrong with just deprecating them?

So, if you were to write .getters['foo/bar'] then you'd get something along the lines of console.warn('Deprecation notice: Slashed getters will be removed in X version - use dotted notation.').

I think adding slashed state too is a bad idea, foo.bar.baz will always be way nicer than foo['bar/baz'] on the eyes. But perhaps I'm alone in thinking this.

sustained avatar Feb 28 '19 15:02 sustained

Is there any plan to merge this PR, or any alternative solution to fix this?

yanni4night avatar Apr 22 '19 07:04 yanni4night

Hello everyone, my dear friend Vasily really wants this feature to be merged, resolve ASAP

graberzz avatar Apr 22 '19 07:04 graberzz

It's been nearly a year since this PR was made and it hasn't even been discussed by a single member of the Vuex team let alone merged. :frowning:

sustained avatar Jun 21 '19 13:06 sustained

I agree with everyone who says that without dot notation it is difficult to read.

It seems that work is already done, but why is it not merged? 😦

Mr-Markus avatar Jul 12 '19 10:07 Mr-Markus

Any updates on this being merged, @hootlex?

caseydwyer avatar Oct 17 '19 20:10 caseydwyer

+1 This would be a really nice feature

jmcudk avatar Oct 22 '19 05:10 jmcudk

I'd also like for this to be merged.

ilyakamens avatar Apr 23 '20 16:04 ilyakamens

Would love to see this merged. Happy to edit/write documentation if that would help.

Jutanium avatar May 26 '20 02:05 Jutanium

I would also love to see this make it in, especially after about the 1000th time of forgetting and just instinctively writing in dot, just to have to go back and fix it all again after the wall of errors.

J5Dev avatar Jul 22 '20 16:07 J5Dev

Adding to this in hopes it will get revisited and merged!

no-stack-dub-sack avatar Dec 08 '20 04:12 no-stack-dub-sack