@@ -36,10 +36,10 @@ class Store {
3636 const store = this
3737 const { dispatch, commit } = this
3838 this . dispatch = function boundDispatch ( type , payload ) {
39- dispatch . call ( store , type , payload )
39+ return dispatch . call ( store , type , payload )
4040 }
4141 this . commit = function boundCommit ( type , payload ) {
42- commit . call ( store , type , payload )
42+ return commit . call ( store , type , payload )
4343 }
4444
4545 // init state and getters
@@ -140,24 +140,27 @@ class Store {
140140 }
141141
142142 commit ( type , payload ) {
143- const entry = this . _mutations [ type ]
144- if ( ! entry ) {
145- console . error ( `[vuex] unknown mutation type: ${ type } ` )
146- return
147- }
148143 // check object-style commit
149144 let mutation
150- if ( isObject ( type ) ) {
145+ if ( isObject ( type ) && type . type ) {
151146 payload = mutation = type
147+ type = type . type
152148 } else {
153149 mutation = { type, payload }
154150 }
151+ const entry = this . _mutations [ type ]
152+ if ( ! entry ) {
153+ console . error ( `[vuex] unknown mutation type: ${ type } ` )
154+ return
155+ }
155156 this . _committing = true
156157 entry . forEach ( function commitIterator ( handler ) {
157158 handler ( payload )
158159 } )
159160 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+ }
161164 }
162165
163166 dispatch ( type , payload ) {
@@ -169,7 +172,7 @@ class Store {
169172 }
170173 return entry . length > 1
171174 ? Promise . all ( entry . map ( handler => handler ( payload ) ) )
172- : Promise . resolve ( entry [ 0 ] ( payload ) )
175+ : entry [ 0 ] ( payload )
173176 }
174177
175178 subscribe ( fn ) {
0 commit comments