vuex-multi-commit

1.2.6 • Public • Published

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.

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i vuex-multi-commit

      Weekly Downloads

      1

      Version

      1.2.6

      License

      MIT

      Unpacked Size

      2.85 kB

      Total Files

      3

      Last publish

      Collaborators

      • p1pchenk0