I think these two syntaxes are equivalent, but is one of them best practice? (lesson code is at the bottom)
// getters
getTask: state =>(id) => {
for (const column of state.board.columns) {
for (const task of column.tasks) {
if (task.id === id) {
return task
}
}
}
}
/src/store.js
...
state: {
board
},
getters: { // <-- Add a getter
getTask (state) {
return (id) => {
for (const column of state.board.columns) {
for (const task of column.tasks) {
if (task.id === id) {
return task
}
}
}
}
}
},
mutations: {}
})
I think these two syntaxes are equivalent, but is one of them best practice? (lesson code is at the bottom)
/src/store.js