title: using generic vuex mutations
body: <p>I have been working in vue/vuex for about a year. In my apps, find myself eventually adding a couple of mutators in my store(s) like so</p>
  
  <pre><code>mutations: {
  ...
  setAny(state, obj){
    Object.keys(obj).forEach(k =&gt; state[k] = obj[k]);
  },
  toggleAny(state, key){//booleans
    state[key] = !state[key];
  }
  ...
  </code></pre>
  
  <p>Then I can quickly get objects or multiple objects in the state with patterns like this:</p>
  
  <pre><code>actions:{
    myAsyncThing:({commit}) =&gt; {
      asyncThing.then(results =&gt; {
        const foo = specialSauceA(results);
        const bar = specialSauceB(foo);
        const baz = specialSauceC(bar);
        commit('setAny', {foo, bar, baz});//slick one liner!
      });
    },
    ...
  },
  state:{
    foo:{},
    bar:{},
    baz:{}
  },
  </code></pre>
  
  <p>I prefer this over writing a mutator for every shared state key I might update. Of course, I also write plenty of custom mutators, but I have been leaning towards this approach when I need to add props to the state that need to be reliably reactive and set from an action or component.</p>
  
  <p>The reason I ask is mostly I wonder why I have never seen any vuex code examples that do this and I wonder why not? When I first did this, I felt naughty, but over time, this pattern has been a huge time saver with no real side effects.</p>
  
  <p>So is there a flaw with this approach given the discussion surrounding breaking state mutations out of actions and into mutations? </p>