Answer the question
In order to leave comments, you need to log in
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;
}
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question