Skip to content

Commit

Permalink
Inline composeMiddleware because it is not used outside applyMiddleware
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Jul 22, 2015
1 parent 100ce3c commit af474ba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 deletions.
18 changes: 5 additions & 13 deletions src/utils/applyMiddleware.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import compose from './compose';
import composeMiddleware from './composeMiddleware';

/**
* Creates a higher-order store that applies middleware to a store's dispatch.
Expand All @@ -11,22 +10,15 @@ import composeMiddleware from './composeMiddleware';
export default function applyMiddleware(...middlewares) {
return (next) => (reducer, initialState) => {
var store = next(reducer, initialState);
var middleware = composeMiddleware(...middlewares);
var composedDispatch = () => {};

function dispatch(action) {
return composedDispatch(action);
}
var dispatch = store.dispatch;
var chain = [];

var middlewareAPI = {
getState: store.getState,
dispatch
dispatch: (action) => dispatch(action)
};

composedDispatch = compose(
middleware(middlewareAPI),
store.dispatch
);
chain = middlewares.map(middleware => middleware(middlewareAPI));
dispatch = compose(...chain, store.dispatch);

return {
...store,
Expand Down
13 changes: 0 additions & 13 deletions src/utils/composeMiddleware.js

This file was deleted.

0 comments on commit af474ba

Please sign in to comment.