Parcourir la source

adjust store registration method names

Evan You il y a 8 ans
Parent
commit
ce60bc7dd5
2 fichiers modifiés avec 8 ajouts et 8 suppressions
  1. 7 7
      src/index.js
  2. 1 1
      test/unit/test.js

+ 7 - 7
src/index.js

@@ -43,7 +43,7 @@ class Store {
     initStoreVM(this, state, {})
 
     // apply root module
-    this.module([], options)
+    this.registerModule([], options)
 
     // apply plugins
     plugins.concat(devtoolPlugin).forEach(plugin => plugin(this))
@@ -63,7 +63,7 @@ class Store {
     this._committing = false
   }
 
-  module (path, module, hot) {
+  registerModule (path, module, hot) {
     this._committing = true
     if (typeof path === 'string') path = [path]
     assert(Array.isArray(path), `module path must be a string or an Array.`)
@@ -75,7 +75,7 @@ class Store {
     this._committing = false
   }
 
-  mutation (type, handler, path = []) {
+  registerMutation (type, handler, path = []) {
     const entry = this._mutations[type] || (this._mutations[type] = [])
     const store = this
     entry.push(function wrappedMutationHandler (payload) {
@@ -83,7 +83,7 @@ class Store {
     })
   }
 
-  action (type, handler, path = []) {
+  registerAction (type, handler, path = []) {
     const entry = this._actions[type] || (this._actions[type] = [])
     const store = this
     const { dispatch, commit } = this
@@ -191,7 +191,7 @@ class Store {
         options.modules[key] = newOptions.modules[key]
       }
     }
-    this.module([], options, true)
+    this.registerModule([], options, true)
   }
 }
 
@@ -259,13 +259,13 @@ function initModule (store, path, module, hot) {
 
   if (mutations) {
     Object.keys(mutations).forEach(key => {
-      store.mutation(key, mutations[key], path)
+      store.registerMutation(key, mutations[key], path)
     })
   }
 
   if (actions) {
     Object.keys(actions).forEach(key => {
-      store.action(key, actions[key], path)
+      store.registerAction(key, actions[key], path)
     })
   }
 

+ 1 - 1
test/unit/test.js

@@ -202,7 +202,7 @@ describe('Vuex', () => {
       strict: true
     })
     expect(() => {
-      store.module('hi', {
+      store.registerModule('hi', {
         state: { a: 1 },
         mutations: { inc: state => state.a++ },
         actions: { inc: ({ commit }) => commit('inc') },