Commit 5a1d94e 1 parent e1bb8f6 commit 5a1d94e Copy full SHA for 5a1d94e
File tree 2 files changed +20
-1
lines changed
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ class AltStore {
72
72
if ( model . reduce ) {
73
73
handleDispatch ( ( ) => {
74
74
const value = model . reduce ( this . state , payload )
75
- if ( value !== undefined ) this . state = value
75
+ if ( value !== undefined ) this . state = model . state = value
76
76
} , payload )
77
77
if ( ! this . preventDefault ) this . emitChange ( )
78
78
}
Original file line number Diff line number Diff line change @@ -171,5 +171,24 @@ export default {
171
171
assert ( store . reduce ( store . state ) . x === 0 )
172
172
assert ( store2 . reduce ( store2 . state ) . x === 1 )
173
173
} ,
174
+
175
+ 'state returned from reduce is set correctly' ( ) {
176
+ const alt = new Alt ( )
177
+ const actions = alt . generateActions ( 'test' ) ;
178
+
179
+ const store = alt . createStore ( {
180
+ displayName : 'store' ,
181
+
182
+ state : { x : 0 } ,
183
+
184
+ reduce ( state ) {
185
+ assert ( state === this . state , 'state matches this.state' ) ;
186
+ return { ...state } ;
187
+ }
188
+ } )
189
+
190
+ actions . test ( ) ;
191
+ actions . test ( ) ;
192
+ } ,
174
193
}
175
194
}
You can’t perform that action at this time.
0 commit comments