title: Structuring a Vuex module
body: <p>I am having some trouble in trying to keep my Vuex modules clean and I was hoping to receive some insight on how to improve this. I have already split up some mutations and am using actions to compose multiple mutations so I guess that is a good start.</p>
  
  <p>In most examples I see super clean mutations and I have those as well but a lot I needs checks with if statements or other side effects. To provide examples:</p>
  
  <p><strong>My action:</strong></p>
  
  <pre><code>setFilteredData({ state, commit }, payload) {
      commit('setFilteredData', payload);
  
      // Check if we need to split up the data into 'hotels' and 'nearby_hotels'.
      if (state.filteredData.find(hotel =&gt; hotel.nearby_city)) {
          commit('splitHotelsAndNearbyHotels', state.filteredData);
      }
  }
  </code></pre>
  
  <p><strong>My mutation:</strong></p>
  
  <pre><code>splitHotelsAndNearbyHotels(state, payload) {
      // Chunk it up into hotels and nearby hotels.
      const composed = groupBy(payload, 'nearby_city');
  
      if (composed.true) {
          composed.true.forEach((hotel) =&gt; {
              if (hotel.isFirst) hotel.isFirst = false;
          });
  
          composed.true[0].isFirst = true;
  
          // Merge them back together in the right order.
          state.filteredData = composed.false.concat(composed.true);
      }
  }
  </code></pre>
  
  <p>In this example if my array of objects contains a hotel with <code>hotel.nearby_city</code> set to <code>true</code> it will perform the commit of <code>splitHotelsAndNearbyHotels</code>.</p>
  
  <p>The code is not transparent enough. The <code>if</code> statement inside the action does not feel right and I would like my mutation to be cleaner.</p>
  
  <p>I have thought about splitting up my <code>splitHotelsAndNearbyHotels</code> into separate functions but I have no idea where to place those. Simply putting them inside the Vuex file does not feel like a big improvement putting them in a separate file could be an option I guess.</p>
  
  <p>How could I clean up my file to improve the readability? Perhaps someone can show me a Vuex example which does not have an ideal scenario like what I am dealing with.</p>