pinia-orm
pinia-orm copied to clipboard
Store is not reactive in Vue 2
Environment
With Vue 2.7.16 and pinia-orm 1.7.2
Reproduction
Not working with pinia-orm 1.7.2 and vue 2: https://stackblitz.com/edit/vue2-vite-starter-yrebbd Working with pinia-orm 1.6.7 and vue 2: https://stackblitz.com/edit/vue2-vite-starter-a2jqrw Working with pinia-orm 1.7.2 and vue 3: https://stackblitz.com/edit/vue2-vite-starter-jn2ym2
Describe the bug
When using Vue 2, Object.assign
is breaking reactivity. When an entity is inserted into a repository, the getter using the repository are not updated.
Additional context
It is possible to verify that the pinia store state is changed via https://pinia.vuejs.org/core-concepts/state.html#Subscribing-to-the-state With Vue 2, we can see that the inner store state is not properly updated via the Object.assign
used in pinia-orm 1.7
Logs
No response
I have the same problem here. I'd like to test the PR in my project but I don't know how to install a JS package from a repo. It's pretty simple in Python but I'm not sure it's possible with NPM.
~~To test the PR you can clone my repo with git clone [email protected]:Graphmaxer/pinia-orm.git
and switch to the branch fix-vue-2-reactivity
then you can build the pinia-orm
package via pnpm install
& pnpm build
and finally you can copy the dist
inside your node_modules
project via cp -r ../pinia-orm/packages/pinia-orm/dist/ node_modules/pinia-orm/
. If you use vite
you must do a vite --force
to clean cache and re-optimize deps.~~
EDIT: I found a simpler way, you can just do npm install 'https://gitpkg.now.sh/Graphmaxer/pinia-orm/packages/pinia-orm?fix-vue-2-reactivity-with-dist'
in your project to test the PR
Thanks @Graphmaxer, that's exactly the kind of solution I had in mind! And good news, the fix works in my case. I hope it will be released soon, it's a critical bug.
That's good to hear, I just discovered this tool to easily create npm packages with github repository https://gitpkg.vercel.app Now it's time to wait for the review and the release :)
@Graphmaxer Well its merged and can be testet with pina-orm edge channel: https://pinia-orm.codedredd.de/guide/getting-started/quick-start#edge-channel
Thank you for the PR and patients ❤️