DEV Community

Discussion on: You Might Not Need Vuex with Vue 3

Collapse
davestewart profile image
Dave Stewart • Edited

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...

Collapse
vuesomedev profile image
Gábor Soós Author

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

Collapse
davestewart profile image
Dave Stewart

Thanks! Can you expand on that?

Thread Thread
vuesomedev profile image
Gábor Soós Author

Just an example on the Readme on how to use it with the app instances use method. app.use(store)

Thread Thread
davestewart profile image
Dave Stewart

There's no use per-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...