File tree Expand file tree Collapse file tree 2 files changed +1
-51
lines changed
Expand file tree Collapse file tree 2 files changed +1
-51
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,6 @@ class Store {
2323 this . _wrappedGetters = Object . create ( null )
2424 this . _runtimeModules = Object . create ( null )
2525 this . _subscribers = [ ]
26- this . _pendingActions = [ ]
2726
2827 // bind commit and dispatch to self
2928 const store = this
@@ -89,15 +88,9 @@ class Store {
8988 console . error ( `[vuex] unknown action type: ${ type } ` )
9089 return
9190 }
92- const res = entry . length > 1
91+ return entry . length > 1
9392 ? Promise . all ( entry . map ( handler => handler ( payload ) ) )
9493 : entry [ 0 ] ( payload )
95- const pending = this . _pendingActions
96- pending . push ( res )
97- return res . then ( value => {
98- pending . splice ( pending . indexOf ( res ) , 1 )
99- return value
100- } )
10194 }
10295
10396 subscribe ( fn ) {
@@ -163,10 +156,6 @@ class Store {
163156 resetStore ( this )
164157 }
165158
166- onActionsResolved ( cb ) {
167- Promise . all ( this . _pendingActions ) . then ( cb )
168- }
169-
170159 _withCommit ( fn ) {
171160 const committing = this . _committing
172161 this . _committing = true
Original file line number Diff line number Diff line change @@ -129,45 +129,6 @@ describe('Vuex', () => {
129129 } )
130130 } )
131131
132- it ( 'onActionsResolved' , done => {
133- const store = new Vuex . Store ( {
134- state : {
135- count : 0
136- } ,
137- mutations : {
138- inc : state => state . count ++
139- } ,
140- actions : {
141- one ( { commit } ) {
142- return new Promise ( r => {
143- commit ( 'inc' )
144- r ( 1 )
145- } )
146- } ,
147- two ( { commit } ) {
148- return new Promise ( r => {
149- setTimeout ( ( ) => {
150- commit ( 'inc' )
151- r ( 2 )
152- } , 0 )
153- } )
154- }
155- }
156- } )
157- store . dispatch ( 'one' )
158- store . dispatch ( 'two' )
159- expect ( store . state . count ) . toBe ( 1 )
160- expect ( store . _pendingActions . length ) . toBe ( 2 )
161- store . onActionsResolved ( res => {
162- expect ( store . _pendingActions . length ) . toBe ( 0 )
163- expect ( store . state . count ) . toBe ( 2 )
164- expect ( res . length ) . toBe ( 2 )
165- expect ( res [ 0 ] ) . toBe ( 1 )
166- expect ( res [ 1 ] ) . toBe ( 2 )
167- done ( )
168- } )
169- } )
170-
171132 it ( 'getters' , ( ) => {
172133 const store = new Vuex . Store ( {
173134 state : {
You can’t perform that action at this time.
0 commit comments