R
R
Riley Usagi2018-02-05 17:10:12
JavaScript
Riley Usagi, 2018-02-05 17:10:12

Vuex computed set method. Why does it work on page load?

computed: {
  complexes: {
    get () {
      return this.complexesFromState
    },
    set (complexId) {
      this.updateSelectedComplexId(complexId)
    }
  }
}

There is a code like this in vuex
Can someone explain to me why the set (value) part fires automatically on page load, and not just on a field change in the form? And can this be somehow avoided?
Why are all actions, mutations, getters, all queries to the database processed, and more than once, when loading the page?
Thank you in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shoomakov, 2018-02-05
@shoomakov

Unfortunately, about queries - you just missed something somewhere or called it in a loop. Mutations are not caused by themselves.
About computed properties. Apparently, you have one more property in the getter, which changes its state when the component is "created", and set is called there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question