Open MetRonnie opened 1 year ago
Taken from now-deleted cylc-ui wiki page on Vue 3:
We might be able to use just the reactivity system of Vue instead of a store with Vuex. i.e. we can build our own with Vue's reactivity.
See: https://vueschool.io/articles/vuejs-tutorials/state-management-with-composition-api/
We can achieve the same as Vuex with just Vue 3. Plus, it allows us to have tree-shaking (discard any code that is not used in our store by the current code in a view, for instance), requires less code, is simpler to understand, and it is also more flexible, giving us more options to manipulate the store.
On flexibility, Vuex allows us to store only data. But with Vue 3 and
reactive
andref
we are exporting objects, so we can also export functions (you cannot store objects with functions in Vuex store). We have modules that are handling the store changes, and also callbacks and delta code that could be hugely simplified.
Pinia is now the preferred store for Vue 3 apps.
https://blog.logrocket.com/pinia-vs-vuex/