MCPcopy
hub / github.com/vuejs/vuex / commit

Method commit

src/store.js:95–130  ·  view source on GitHub ↗
(_type, _payload, _options)

Source from the content-addressed store, hash-verified

93 }
94
95 commit (_type, _payload, _options) {
96 // check object-style commit
97 const {
98 type,
99 payload,
100 options
101 } = unifyObjectStyle(_type, _payload, _options)
102
103 const mutation = { type, payload }
104 const entry = this._mutations[type]
105 if (!entry) {
106 if (__DEV__) {
107 console.error(`[vuex] unknown mutation type: ${type}`)
108 }
109 return
110 }
111 this._withCommit(() => {
112 entry.forEach(function commitIterator (handler) {
113 handler(payload)
114 })
115 })
116
117 this._subscribers
118 .slice() // shallow copy to prevent iterator invalidation if subscriber synchronously calls unsubscribe
119 .forEach(sub => sub(mutation, this.state))
120
121 if (
122 __DEV__ &&
123 options && options.silent
124 ) {
125 console.warn(
126 `[vuex] mutation type: ${type}. Silent option has been removed. ` +
127 'Use the filter functionality in the vue-devtools'
128 )
129 }
130 }
131
132 dispatch (_type, _payload) {
133 // check object-style dispatch

Callers 6

index.tsFile · 0.80
modules.spec.jsFile · 0.80
helpers.spec.jsFile · 0.80
store.spec.jsFile · 0.80
hot-reload.spec.jsFile · 0.80
makeLocalContextFunction · 0.80

Calls 3

_withCommitMethod · 0.95
unifyObjectStyleFunction · 0.90
handlerFunction · 0.50

Tested by

no test coverage detected