neuronetio / gantt-elastic

Gantt Chart [ javascript gantt chart, gantt component, vue gantt, vue gantt chart, responsive gantt, project manager , vue projects ]

Home Page:https://neuronet.io/gantt-elastic/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Proposal: Would you like to make the props tasks immutable?

somen440 opened this issue · comments

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.

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.

gantt-elastic 0.10.0 has been refactorized and now works internally on vuex