title: Using Object Assign to clear state
body: <p>This is my state:</p>
  
  <pre><code>export default new Vuex.Store({
    state: {
      items: [
      ],
      user: {
        isAuthenticated: false,
        info: {
          createdAt: '',
          email: '',
          firstName: '',
          id: '',
          lastName: '',
        },
        token: {
          accessToken: '',
          expiresIn: '',
          refreshToken: '',
          tokenType: '',
        },
      },
    },
    actions,
    mutations,
    getters,
    plugins: [createPersistedState({
      key: 'persistedState',
      paths: ['user'],
    })],
    strict: process.env.NODE_ENV !== 'production',
  });
  </code></pre>
  
  <p>I keep separately the default state of user - so I don't have to manually reset every property when necessary.</p>
  
  <pre><code>export const defaultUser = {
    isAuthenticated: false,
    info: {
      createdAt: '',
      email: '',
      firstName: '',
      id: '',
      lastName: '',
    },
    token: {
      accessToken: '',
      expiresIn: '',
      refreshToken: '',
      tokenType: '',
    },
  };
  </code></pre>
  
  <p>So, when a logout action is triggered:</p>
  
  <pre><code>export const logout = ({ commit, dispatch }) =&gt; {
    commit(types.LOGOUT_USER);
    dispatch('changeStatus', 'You need to login or register.');
  };
  
  
  
  [types.LOGOUT_USER](state) {
    Object.assign(state.user, defaultUser);
  },
  </code></pre>
  
  <p>but magically sometimes the entire user object seems to not have been replaced... (or the defaultState object is filled with the last values?)</p>