Proposal: Would you like to make the props tasks immutable?
somen440 opened this issue · comments
satoya commented
Problem
- If you have tasks as the state of vuex, you need to prepare a copy object of tasks separately
...
export const state = () => ({
tasks: [],
...
...
...
})
...
Error: [vuex] do not mutate vuex store state outside mutation handlers.
<GanttElastic :tasks="tasks" :options="options">
...
...
computed: {
...mapState(['tasks']),
...
...
In order to avoid this
<GanttElastic :tasks="copyTasks" :options="options">
...
...
data() {
return {
copyTasks: []
}
}
...
...
computed: {
...mapState(['tasks']),
...
...
created() {
this.copyTasks = JSON.parse(JSON.stringify(this.tasks)) // need to copy
}
Proposal contents
Copy in elastic gantt component
Advantages and disadvantages
- Advantages
- There is no need to copy on the caller side. To be simple :)
- Disadvantages
- Failure occurs when caller expects change.
neuronet.io commented
mhm, I was thinking about this for some time.
I will correct some minor bugs and then I will refactor gantt.
Options should be immutable too.
Thanks for pointing out.
neuronet.io commented
gantt-elastic 0.10.0 has been refactorized and now works internally on vuex