I've been investigating similar functionality recently, and wrapped up shared stores into a class-based format, that works in Vue 2, 3 and Nuxt and supports state, getters, watches, actions (methods) and inheritance:
The library is a single decorator that allows you to use a single interface (classes) and returns you a working store in Vue 2 (as a new Vue) or Vue 3 (using the Reactivity API).
Check the docs for provide/inject example and demos for working code:
Hey,
Nice article!
I've been investigating similar functionality recently, and wrapped up shared stores into a class-based format, that works in Vue 2, 3 and Nuxt and supports state, getters, watches, actions (methods) and inheritance:
github.com/davestewart/vue-class-s...
The library is a single decorator that allows you to use a single interface (classes) and returns you a working store in Vue 2 (as a new Vue) or Vue 3 (using the Reactivity API).
Check the docs for provide/inject example and demos for working code:
github.com/davestewart/vue-class-s...
Nice work, looks amazing 👍
One idea: add an example on how to use it as a plugin...or publish a plugin also in the package
Thanks! Can you expand on that?
Just an example on the Readme on how to use it with the
appinstancesusemethod.app.use(store)There's no
useper-se, you just create the models and use them where you need them.If you want a "global" style example, either import as needed or use inject exactly as you have (example code in the README):
github.com/davestewart/vue-class-s...