A
A
Alexey Shashenkov2017-05-31 18:32:30
Vue.js
Alexey Shashenkov, 2017-05-31 18:32:30

How to get rootState or other state in mutations with namespaced enabled?

In general, I broke vuex into modules. Now I want to transfer the general functions to the root module (namespaced is disabled in it).
Now the only thought is to forward the desired state from the action and mutate it.
Maybe there are other ways?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav, 2020-04-15
@VladZen

I don’t know how good this practice is, but you can get `rootState` inside the mutation through `this.state`, but I repeat: this is more of an undocumented feature, and LinusBorg itself advises using plugins and synchronizing states of different levels, but as for me, this unnecessarily complicates architecture, and sooner or later you can potentially stumble upon an infinite loop.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question