Skip to content

p1pchenk0/vuex-multi-commit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

vuex-multi-commit

npm npm

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.

About

Allow working with Vuex 3.x mutations in more fancy way by passing object or array of mutations to single "commit" call

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published