Created
November 8, 2018 17:41
-
-
Save simistern/8c06367965f20241ba31c31de47263c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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