davestewart / vuex-pathify

Vue / Vuex plugin providing a unified path syntax to Vuex stores
https://davestewart.github.io/vuex-pathify
MIT License
1.37k stars 57 forks source link

hi,there. how can i do the dispatch with vuex-pathify ?could vuex-pathify deal with vuex actions? #120

Closed radiorz closed 3 years ago

radiorz commented 3 years ago

the way to get values from vuex store with vuex-pathify is great.but how can i do the dispatch and commit (change the values inside state).

davestewart commented 3 years ago

Hi @radiorz.

Sorry if that's not clear...

The component helper sync() will build computed properties which do dispatches / commits inside itself.

If you want to attach methods to your components which call actions of the same name, you can use call() which will is effectively the same as mapActions().

You can also use this.$store.set('value', value) which will (depending on your config) target actions or commits (dispatch('setValue', value) or commit('value', value)).

Finally, you can import { commit, disptach } from 'vuex-pathify' which are effectively proxies for store.commit(...) and store.dispatch(...).

Make sense?

radiorz commented 3 years ago

cool thanks @davestewart it helps.

davestewart commented 3 years ago

Good luck, and have fun with it!