jmacnc
jmacnc

Reputation: 163

Committing a mutation from another module

I would like to reset the state of my stores upon a logout action. I created mutations in each store to reset the state.

I tried doing something like this with no luck.

logout: function ({commit}) {
        commit('resetLoginState')
        commit('menu.resetMenuState')
    }

the logout function is in my login module and the resetMenuState is in another module called menu

Is it possible to do this?

Upvotes: 4

Views: 4127

Answers (1)

Dawid Kisielewski
Dawid Kisielewski

Reputation: 829

You can use:

commit('path/from/root/to/your/module/menu/resetMenuState', null, { root: true })

you can read more about it on this page

Upvotes: 5

Related Questions