vuex-multi-commit
v1.2.6
Published
Allow working with Vuex 3.x mutations in more fancy way by passing object or array of mutations to single 'commit' call
Downloads
13
Readme
vuex-multi-commit
This package allows to combine code needed to commit multiple mutations inside one commit
call.
Installation
import Vuex from 'vuex'
import 'vuex-multi-commit'
Vue.use(Vuex)
For NUXT import this package inside main store module or inside store.js
file
Usage
Instead of:
this.$store.commit('doThis')
this.$store.commit('doThat')
You can write:
this.$store.commit(['doThis', 'doThat'])
Instead of this:
this.$store.commit('doThis')
this.$store.commit('doThat', 200300)
this.$store.commit('andDoThis', 300600)
this.$store.commit('andAlsoDoThat', 400700)
You can do:
this.$store.commit([
'doThis',
{
'doThat': 200300,
'andDoThis': 300600,
'andAlsoDoThat': 400700
}
])
If you want, you can use single object:
this.$store.commit({
'doThis': 100500,
'doThat': 200300,
'andDoThis': 300600,
'andAlsoDoThat': 400700
})
Unfortunately, so far this package doesn't allow to use arrays or objects inside store modules except root.