Skip to content

Instantly share code, notes, and snippets.

@MaximeHeckel
Last active December 28, 2018 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaximeHeckel/e640030e305c5ae9d38f133e1c032631 to your computer and use it in GitHub Desktop.
Save MaximeHeckel/e640030e305c5ae9d38f133e1c032631 to your computer and use it in GitHub Desktop.
import { createStore, applyMiddleware } from 'redux';
import appMiddleware from './middlewares';
import reducer from './reducer';
const history = { push: () => {}, location: { pathname: '/' } };
const getStore = (middlewares, initialState) => {
let actions = [];
const store = createStore(
reducer,
initialState,
applyMiddleware(
...appMiddleware(
{
history,
...middlewares,
},
false,
),
() => next => action => {
if (action.type) {
actions.push(action);
}
return next(action);
},
),
);
store.getActions = () => {
return actions;
};
return store;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment