Pārlūkot izejas kodu

feat(store): bind mutation and action handlers to store (#872)

Pooya Parsa 7 gadi atpakaļ
vecāks
revīzija
67da622555
1 mainītis faili ar 2 papildinājumiem un 2 dzēšanām
  1. 2 2
      src/store.js

+ 2 - 2
src/store.js

@@ -373,14 +373,14 @@ function makeLocalGetters (store, namespace) {
 function registerMutation (store, type, handler, local) {
 function registerMutation (store, type, handler, local) {
   const entry = store._mutations[type] || (store._mutations[type] = [])
   const entry = store._mutations[type] || (store._mutations[type] = [])
   entry.push(function wrappedMutationHandler (payload) {
   entry.push(function wrappedMutationHandler (payload) {
-    handler(local.state, payload)
+    handler.call(store, local.state, payload)
   })
   })
 }
 }
 
 
 function registerAction (store, type, handler, local) {
 function registerAction (store, type, handler, local) {
   const entry = store._actions[type] || (store._actions[type] = [])
   const entry = store._actions[type] || (store._actions[type] = [])
   entry.push(function wrappedActionHandler (payload, cb) {
   entry.push(function wrappedActionHandler (payload, cb) {
-    let res = handler({
+    let res = handler.call(store, {
       dispatch: local.dispatch,
       dispatch: local.dispatch,
       commit: local.commit,
       commit: local.commit,
       getters: local.getters,
       getters: local.getters,