File tree Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ export default class Redux {
37
37
setState ( nextState ) {
38
38
this . state = nextState ;
39
39
this . listeners . forEach ( listener => listener ( ) ) ;
40
+ return nextState ;
40
41
}
41
42
42
43
subscribe ( listener ) {
Original file line number Diff line number Diff line change @@ -2,12 +2,10 @@ import compose from './utils/composeMiddleware';
2
2
3
3
export default function createDispatcher ( store , middlewares = [ ] ) {
4
4
return function dispatcher ( initialState , setState ) {
5
- let state = store ( initialState , { } ) ;
6
- setState ( state ) ;
5
+ let state = setState ( store ( initialState , { } ) ) ;
7
6
8
7
function dispatch ( action ) {
9
- state = store ( state , action ) ;
10
- setState ( state ) ;
8
+ state = setState ( store ( state , action ) ) ;
11
9
return action ;
12
10
}
13
11
Original file line number Diff line number Diff line change @@ -10,11 +10,15 @@ const { ADD_TODO } = constants;
10
10
describe ( 'createDispatcher' , ( ) => {
11
11
12
12
it ( 'should handle sync and async dispatches' , done => {
13
- const spy = expect . createSpy ( ( ) => { } ) ;
13
+ const spy = expect . createSpy (
14
+ nextState => nextState
15
+ ) . andCallThrough ( ) ;
16
+
14
17
const dispatcher = createDispatcher (
15
18
composeStores ( { todoStore } ) ,
16
19
// we need this middleware to handle async actions
17
- getState => [ thunkMiddleware ( getState ) ] ) ;
20
+ getState => [ thunkMiddleware ( getState ) ]
21
+ ) ;
18
22
19
23
expect ( dispatcher ) . toBeA ( 'function' ) ;
20
24
You can’t perform that action at this time.
0 commit comments