@@ -36,10 +36,10 @@ class Store {
36
36
const store = this
37
37
const { dispatch, commit } = this
38
38
this . dispatch = function boundDispatch ( type , payload ) {
39
- dispatch . call ( store , type , payload )
39
+ return dispatch . call ( store , type , payload )
40
40
}
41
41
this . commit = function boundCommit ( type , payload ) {
42
- commit . call ( store , type , payload )
42
+ return commit . call ( store , type , payload )
43
43
}
44
44
45
45
// init state and getters
@@ -140,24 +140,27 @@ class Store {
140
140
}
141
141
142
142
commit ( type , payload ) {
143
- const entry = this . _mutations [ type ]
144
- if ( ! entry ) {
145
- console . error ( `[vuex] unknown mutation type: ${ type } ` )
146
- return
147
- }
148
143
// check object-style commit
149
144
let mutation
150
- if ( isObject ( type ) ) {
145
+ if ( isObject ( type ) && type . type ) {
151
146
payload = mutation = type
147
+ type = type . type
152
148
} else {
153
149
mutation = { type, payload }
154
150
}
151
+ const entry = this . _mutations [ type ]
152
+ if ( ! entry ) {
153
+ console . error ( `[vuex] unknown mutation type: ${ type } ` )
154
+ return
155
+ }
155
156
this . _committing = true
156
157
entry . forEach ( function commitIterator ( handler ) {
157
158
handler ( payload )
158
159
} )
159
160
this . _committing = false
160
- this . _subscribers . forEach ( sub => sub ( mutation , this . state ) )
161
+ if ( ! payload || ! payload . silent ) {
162
+ this . _subscribers . forEach ( sub => sub ( mutation , this . state ) )
163
+ }
161
164
}
162
165
163
166
dispatch ( type , payload ) {
@@ -169,7 +172,7 @@ class Store {
169
172
}
170
173
return entry . length > 1
171
174
? Promise . all ( entry . map ( handler => handler ( payload ) ) )
172
- : Promise . resolve ( entry [ 0 ] ( payload ) )
175
+ : entry [ 0 ] ( payload )
173
176
}
174
177
175
178
subscribe ( fn ) {
0 commit comments