Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
YvetteLau committed Oct 4, 2019
1 parent c4b5ad5 commit efce8ab
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions myredux/to-redux2/src/redux/applyMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ import compose from './compose';

const applyMiddleware = (...middlewares) => createStore => (...args) => {
let store = createStore(...args);
let middles = middlewares.map(middleware => middleware(store));
let dispatch = compose(...middles)(store.dispatch);
let dispatch;
const middlewareAPI = {
getState: store.getstate,
dispatch: (...args) => dispatch(...args)
}
let middles = middlewares.map(middleware => middleware(middlewareAPI));
dispatch = compose(...middles)(store.dispatch);
return {
...store,
dispatch
Expand Down

0 comments on commit efce8ab

Please sign in to comment.