Robstar liked a comment+100 XP
3w ago
You can use object destructuring with pinia, you just have to use storeToRefs (https://pinia.vuejs.org/core-concepts/#Destructuring-from-a-Store) for all reactive properties.
const cartStore = useCartStore();
const { cart, subtotal, taxes, total } = storeToRefs(cartStore);
const { incrementProduct } = cartStore;
Robstar liked a comment+100 XP
3w ago
For working with local storage, I like to use VueUse's useStorage (https://vueuse.org/core/useStorage/), which makes the local storage reactive.
Robstar wrote a comment+100 XP
1mo ago
I'd probably reach for a composable here as it's much clearer as where the data is from. The coupling is very low too as the composable can be used anywhere in the app. For myself, they're the closest thing to Vuex / Pinia, without using Vuex / Pinia (although everytime I've opted out of using Pinia I've always regretted it - you can see how complicated things get wehn you have nested com,ponents, as in this shoipping cart demo).