Преглед изворни кода

narrow dispatching state to only mutation handlers

Evan You пре 9 година
родитељ
комит
e688e3d8c3
1 измењених фајлова са 2 додато и 2 уклоњено
  1. 2 2
      src/index.js

+ 2 - 2
src/index.js

@@ -59,18 +59,19 @@ export default class Vuex {
    */
 
   dispatch (type, ...payload) {
-    this._dispatching = true
     const mutation = this._mutations[type]
     const prevSnapshot = this._prevSnapshot
     const state = this.state
     let snapshot, clonedPayload
     if (mutation) {
+      this._dispatching = true
       // apply the mutation
       if (Array.isArray(mutation)) {
         mutation.forEach(m => m(state, ...payload))
       } else {
         mutation(state, ...payload)
       }
+      this._dispatching = false
       // invoke middlewares
       if (this._needSnapshots) {
         snapshot = this._prevSnapshot = deepClone(state)
@@ -86,7 +87,6 @@ export default class Vuex {
     } else {
       console.warn(`[vuex] Unknown mutation: ${ type }`)
     }
-    this._dispatching = false
   }
 
   /**