vuex
vuex copied to clipboard
WIP feat: access namespaced getters using the dot notation
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
cc @kazupon @ktsn @simplesmiler
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!
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 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.
Any updates on this PR?
@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.
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.
Is there any plan to merge this PR, or any alternative solution to fix this?
Hello everyone, my dear friend Vasily really wants this feature to be merged, resolve ASAP
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:
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? 😦
Any updates on this being merged, @hootlex?
+1 This would be a really nice feature
I'd also like for this to be merged.
Would love to see this merged. Happy to edit/write documentation if that would help.
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.
Adding to this in hopes it will get revisited and merged!