8000 adjust store registration method names · vuejs/v2.vuejs.org@ce60bc7 · GitHub
[go: up one dir, main page]

Skip to content

Commit ce60bc7

Browse files
committed
adjust store registration method names
1 parent 7d89380 commit ce60bc7

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Store {
4343
initStoreVM(this, state, {})
4444

4545
// apply root module
46-
this.module([], options)
46+
this.registerModule([], options)
4747

4848
// apply plugins
4949
plugins.concat(devtoolPlugin).forEach(plugin => plugin(this))
@@ -63,7 +63,7 @@ class Store {
6363
this._committing = false
6464
}
6565

66-
module (path, module, hot) {
66+
registerModule (path, module, hot) {
6767
this._committing = true
6868
if (typeof path === 'string') path = [path]
6969
assert(Array.isArray(path), `module path must be a string or an Array.`)
@@ -75,15 +75,15 @@ class Store {
7575
this._committing = false
7676
}
7777

78-
mutation (type, handler, path = []) {
78+
registerMutation (type, handler, path = []) {
7979
const entry = this._mutations[type] || (this._mutations[type] = [])
8080
const store = this
8181
entry.push(function wrappedMutationHandler (payload) {
8282
handler(getNestedState(store.state, path), payload)
8383
})
8484
}
8585

86-
action (type, handler, path = []) {
86+
registerAction (type, handler, path = []) {
8787
const entry = this._actions[type] || (this._actions[type] = [])
8888
const store = this
8989
const { dispatch, commit } = this
@@ -191,7 +191,7 @@ class Store {
191191
options.modules[key] = newOptions.modules[key]
192192
}
193193
}
194-
this.module([], options, true)
194+
this.registerModule([], options, true)
195195
}
196196
}
197197

@@ -259,13 +259,13 @@ function initModule (store, path, module, hot) {
259259

260260
if (mutations) {
261261
Object.keys(mutations).forEach(key => {
262-
store.mutation(key, mutations[key], path)
262+
store.registerMutation(key, mutations[key], path)
263263
})
264264
}
265265

266266
if (actions) {
267267
Object.keys(actions).forEach(key => {
268-
store.action(key, actions[key], path)
268+
store.registerAction(key, actions[key], path)
269269
})
270270
}
271271

test/unit/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ describe('Vuex', () => {
202202
strict: true
203203
})
204204
expect(() => {
205-
store.module('hi', {
205+
store.registerModule('hi', {
206206
state: { a: 1 },
207207
mutations: { inc: state => state.a++ },
208208
actions: { inc: ({ commit }) => commit('inc') },

0 commit comments

Comments
 (0)
0