What's the technical difference between next two approaches? Example is trivial but when I have huge nested objects, I need to pass lots of IDs in order to find desired object inside the mutation.
In second example I pass an array and just mutate it. Again, technically in both examples we invoke the same push method. Am I right? Should be the same.
const state = () => ({
cards: []
});
mutations: {
addCard(state, card) {
state.cards.push(card)
}
}
// Component...
this.$store.commit('addCard', {...card});
and
const state = () => ({
cards: []
});
mutations: {
addCard(state, data) {
data.cards.push(data.card)
}
}
// Component...
this.$store.commit('addCard', { cards: this.$store.cards, card: {...card} });