File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,11 @@ class Store {
7777 */
7878
7979 dispatch ( type , ...payload ) {
80+ // compatibility for object actions, e.g. FSA
81+ if ( typeof type === 'object' && type . type && arguments . length === 1 ) {
82+ payload = [ type ]
83+ type = type . type
84+ }
8085 const mutation = this . _mutations [ type ]
8186 const prevSnapshot = this . _prevSnapshot
8287 const state = this . state
Original file line number Diff line number Diff line change @@ -386,4 +386,22 @@ describe('Vuex', () => {
386386 done ( )
387387 } )
388388 } )
389+
390+ it ( 'object-format mutations' , ( ) => {
391+ const store = new Vuex . Store ( {
392+ state : {
393+ a : 1
394+ } ,
395+ mutations : {
396+ [ TEST ] ( state , action ) {
397+ state . a += action . by
398+ }
399+ }
400+ } )
401+ store . dispatch ( {
402+ type : TEST ,
403+ by : 2
404+ } )
405+ expect ( store . state . a ) . to . equal ( 3 )
406+ } )
389407} )
You can’t perform that action at this time.
0 commit comments