A
A
Alex Wells2017-07-30 20:49:55
Vue.js
Alex Wells, 2017-07-30 20:49:55

Responsibility of vuex action?

Hello. I'm using vue2 + vuex, with something like this structure.
Question: what should be the responsibility of action'ov? For example, there is an action:

setLocale({commit}, obj) {
        commit(TYPES.SET_LOCALE, obj);
        Vue.cookie.set('locale', obj, { expires: '5Y' }); // 5 years
        i18n.locale = obj;
    }

This method is later mapped into the component and used directly. Should I take it all somewhere? Otherwise, I get that I have business logic in the vuex store, which is clearly not correct.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Kulakov, 2017-07-30
@Alex_Wells

Components call actions to move to a specific state. Actions interact with services that provide the necessary data to change state.
Locale management can be thought of as a service. So IMHO everything is fine.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question