Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

namespaces cannot be arrays for nested modules (supported by vuex) #34

Closed
jskrzypek opened this issue Aug 8, 2017 · 2 comments
Closed

Comments

@jskrzypek
Copy link
Contributor

Steps to reproduce

You cannot provide string array namespaces to feathers-vuex.

I've made an example repo here: https://github.com/jskrzypek/feathers-chat-vuex/tree/array-namespaces. If you clone & install from this branch the app will fail.

You can swap the commented line here to make it work:
https://github.com/jskrzypek/feathers-chat-vuex/blob/array-namespaces/src/api/feathers-client.js#L25-L26

While it's working you can inspect the vuex store with vue-devtools and see that it looks something like this:
feathers-chat-vuex

Expected behavior

Providing namespaces as arrays should allow the user to create service-modules at arbitrarily deep levels of module nesting as described here: https://github.com/vuejs/vuex/blob/dd7f8178d93e6121a447c410b9c652f40cd80937/docs/en/modules.md#dynamic-module-registration

Actual behavior

When you switch the line comments as I mentioned above, you can notice that while the getters work to target the right state information, the modules states are not correctly nested. Look at my todos module's state, the tasks there is actually the state of a nested submodule with the namespace todos/tasks/. todos/otherTasks is another module, that looks nested, but is not.
The todos/tasks/ module obeys the desired behavior for nested modules because an array is passed as the namespace to store.registerModule(), something that currently is not possible with feathers-vuex.

For a more in-depth look, I added a breakpoint after these lines so you can see the inner workings of the vuex module:
feathers-chat-vuex

FWIW, the logic for resolving getters according to namespaces is the same regardless of whether a single string or an array is used, so this app continues to work even when the child modules are not really children, but there may be points at which this behavior breaks down.

System configuration

Tell us about the applicable parts of your setup.

Module versions (especially the part that's not working):

{
  "babel-polyfill": "^6.23.0",
  "date-fns": "^2.0.0-alpha.1",
  "deep-assign": "^2.0.0",
  "feathers": "^2.1.4",
  "feathers-authentication-client": "^0.3.2",
  "feathers-authentication-popups": "^0.1.2",
  "feathers-hooks": "^2.0.1",
  "feathers-reactive": "^0.4.1",
  "feathers-socketio": "^2.0.0",
  "feathers-vuex": "^0.7.2",
  "getbase": "^3.4.2",
  "global": "^4.3.2",
  "rubberduck": "^1.1.1",
  "rxjs": "^5.4.1",
  "steal": "^1.5.4",
  "vue": "^2.3.4",
  "vue-router": "^2.6.0",
  "vuex": "^2.3.1"
}

NodeJS version:
Observed on node@8.2.1, node@6.11.1
Operating System:
Os X Sierra 10.12.6
Browser Version:
Chrome 61.0.3163.31 (Official Build) beta (64-bit)

@jskrzypek
Copy link
Contributor Author

jskrzypek commented Aug 8, 2017

FWIW, my PR #35 fixes this issue. You can run this to check it:

npm install jskrzypek/feathers-vuex#feat-array-namespaces

When you revert the changes to the commented line here and restart, the app will now load.

@daffl
Copy link
Member

daffl commented Aug 18, 2017

Closed via #35 and released as v0.8.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants