Commit object on Vue X (via Actions)… possible?

I’ve a question about Vue X and actions (with commit).

It’s possible to input object in Commit ?

Same as :

...
action{
  ResetLoginStats({commit}){
    commit({
      'SetMutation1':false,
      'SetMutation2':true,
      'SetMutation3':''
      ...
    });
  }
  ...
}

All the part of Action :

ResetSignInStats({ commit }) {
            document.getElementById('Semail').value = '';
            document.getElementById('Spwd').value = '';
            document.getElementById('SpwdC').value = '';
            document.getElementById('Sname').value = '';
            document.getElementById('SBio').value = '';

            commit('setsubFailure', false);
            commit('setMSGfaillure','');
            commit('setsubOkay', false);
            commit('setsubCompleted', false);
            commit('setCHKeMail', false);
            commit('setCHKpassword', false);
            commit('setCHKuserName', false);
            commit('setLoading', false);
        },

Thank you for help & return. Regards!

Answer

Yes you can do it like this

...
action{
  ResetLoginStats({commit}){
    commit('SetMutation1', false);
    commit('SetMutation2', true);
    commit('SetMutation3', '');
  }
  ...
}

Details here https://vuex.vuejs.org/guide/mutations.html#commit-with-payload

Leave a Reply

Your email address will not be published. Required fields are marked *