Skip to content

Instantly share code, notes, and snippets.

@simistern
Created November 8, 2018 17:41
Show Gist options
  • Save simistern/8c06367965f20241ba31c31de47263c0 to your computer and use it in GitHub Desktop.
Save simistern/8c06367965f20241ba31c31de47263c0 to your computer and use it in GitHub Desktop.
import { applyMiddleware as applyReduxMiddleware, createStore as createReduxStore } from "redux";
import { composeWithDevTools as composeWithReduxDevTools } from "redux-devtools-extension";
import reduxThunk from "redux-thunk";
import debounce from "debounce-promise";
import reducer from "../reducer";
import DataCache from "../dataCache";
const logger = store => next => action => { return next(action); };
export const setupStore({ httpApi }) => {
const middlewares = [];
httpApi = await debounce(httpApi, 300); //Not working
middlewares.push(
reduxThunk.withExtraArgument({
httpApi: httpApi,
dataCache: new DataCache(),
}),
);
if (process.env.NODE_ENV === "development") {
middlewares.push(logger);
}
return createReduxStore(
reducer,
composeWithReduxDevTools(applyReduxMiddleware(...middlewares)),
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment