Array property item insert / remove not reflected in store via events
See original GitHub issueSteps to reproduce
Patch a model that has an array property (e.g. someModel.nestedItems
)
Any removals / additions to the array property are not reflected in other clients even though real-time events arrive as they should.
A repo to reproduce: https://github.com/Palivonas/feathers-vuex-bug-reproduction/commit/fa3a592d9dc24be43b20bccf894f13f265bfa4bc
npm install
backend and frontend, runnpm start
andnpm run serve
.- Open localhost:8080, add an item (
create
called immediately) - Open a second browser window, click “disable cloning” in that second window, this will use item reference directly to render the form (instead of a clone) in order to see live changes
- Try adding or removing items in the first window (and clicking save)
Expected behavior
Items are added/removed to/from item.nestedItems throughout all connected clients
Actual behavior
Items are not added/removed in the second client instance. Data is correct after a refresh.
No such issue with FeathersVuex version 1.1.4 (using store action instead of model instances, cause it’s not available in 1.1.4) Events are arriving via websockets without problems.
Module versions:
"@feathersjs/feathers": "^3.3.0",
"@feathersjs/socketio-client": "^1.2.0",
"feathers-vuex": "^1.6.2",
"socket.io-client": "^2.2.0",
NodeJS version: 10
Operating System: MacOS
Browser Version: Chrome 71
Module Loader: Webpack (Vue CLI default setup)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
This is fixed in
feathers-vuex@1.7.0-pre.44
.npm i feathers-vuex@pre
. You can see the implementation and test in the above-referenced commit. Thanks for pointing this out, everybody. Thanks for the issue @Palivonas 🍻I can confirm that setting
store.state.myservice.replaceItems = true
in my store module eliminates the issue.The question remains. Why does _merge walk enumerable properties of a model property value. It should walk the properties of the model but the values of those properties.