D
D
danilr2019-04-16 08:09:30
JavaScript
danilr, 2019-04-16 08:09:30

Is it possible to write the state in Vuex getters somehow?

There are getters in vuex that filters a large array, is it possible somehow to write the final result (the resulting array) into the state?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeniy S, 2019-04-16
@evgensenin

<input v-model="a">
// ...
computed: {
  a: {
    get () {
      return this.$store.state.a
    },
    set (value) {
      this.$store.commit('updateA', value)
    }
  }
}

K
Konstantin Kitmanov, 2019-04-16
@k12th

What for? Vuex getters are memoized, only recalculated if something has changed.
In principle, it is possible to watch change in some component (or directly) and put it in the state, but there is no need.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question