vuex-dot icon indicating copy to clipboard operation
vuex-dot copied to clipboard

Passing path for generalized mutations?

Open ArnoBuschmann opened this issue 6 years ago • 0 comments

Hi :)

One thought, not sure if it makes sense, but wouldn't it be nice to be able to pass the path aside key and value to be able to have generalized mutations?

For example:

  computed: {
    ...takeState('wizard.user')
      .expose([
        'name',
        'email'
      ])
      // .commit('EDIT_USER')
     .commit('EDIT_ANY_GIVEN_PATH')
     .map()
  }

  mutations: {
    // EDIT_USER(state, { key, value }) {
    EDIT_ANY_GIVEN_PATH(state, { key, value, path }) {
      // Vue.set(state.wizard.user, key, value);
      Vue.set(state[path], key, value);
    }
  }

ArnoBuschmann avatar Jun 16 '18 11:06 ArnoBuschmann