Why should I use Pinia instead of Classes? #831
-
Why should anyone use Pinia instead of JS or TS Classes? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
https://pinia.esm.dev/introduction.html#why-should-i-use-pinia |
Beta Was this translation helpful? Give feedback.
-
OK. It adds DX and SSR. Awesome, I love it! But what I actually meant to ask is:
We already used Example of store in my work project which annoys the hell out of me: import items from '../getters/_items'
import actions from '../getters/_actions'
import stock from '../getters/_stock'
import pending from '../getters/_pending'
import cost from '../getters/_cost'
import price from '../getters/_price'
const type = `chemical`
export default {
namespaced: true,
getters: {
items: items(type),
purchases: actions(type, 'purchases'),
sell: actions(type, 'sell'),
write_off: actions(type, 'write_off'),
stock: stock(type),
pending: pending(type),
cost: cost(type),
price: price(type),
...
} It just feels like reinventing the wheel. Wouldn't this make more sense? I stole and updated the Cart from example: https://stackblitz.com/edit/github-eyireq?file=src/models/cart.js Maybe we could create a DX, SSR friendly class called Pinia? class Cart extends Pinia {
// and now our cart has DX and SSR support
} |
Beta Was this translation helpful? Give feedback.
https://pinia.esm.dev/introduction.html#why-should-i-use-pinia