Skip to content
This repository has been archived by the owner on Jan 5, 2022. It is now read-only.

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

Closed
somen440 opened this issue Feb 17, 2019 · 2 comments
Closed

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

somen440 opened this issue Feb 17, 2019 · 2 comments
Labels
✔ approved It landed on the todo list ✔ done 💹 enhancement New feature or request

Comments

@somen440
Copy link
Contributor

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.
@neuronetio
Copy link
Owner

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.

@neuronetio neuronetio added the 💹 enhancement New feature or request label Feb 17, 2019
@neuronetio neuronetio added ▶ work in progress ✔ approved It landed on the todo list labels Feb 25, 2019
@neuronetio
Copy link
Owner

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
✔ approved It landed on the todo list ✔ done 💹 enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants