Skip to content

Instantly share code, notes, and snippets.

@MaximeHeckel
Last active December 28, 2018 14:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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