Closed
Description
Here are some example on how to create a redux store. From the readme:
let store = createStore(counter);
From http://rackt.github.io/redux/docs/advanced/Middleware.html
let createStoreWithMiddleware = applyMiddleware(logger, crashReporter)(createStore);
let todoApp = combineReducers(reducers);
let store = createStoreWithMiddleware(todoApp);
From https://github.com/gaearon/redux-devtools
const finalCreateStore = compose(
// Enables your middleware:
applyMiddleware(thunk),
// Provides support for DevTools:
devTools(),
// Lets you write ?debug_session=<name> in address bar to persist debug sessions
persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/)),
createStore
);
So sometimes you use createStore
, sometimes createStoreWithMiddleware
, sometimes compose
.
I have to say that this is quite confusing. I understand that there is a lot of flexibility here but it will be nicer if there could be only one canonical way to build the final store, e.g. I I don't need any middleware then I just pass an empty array.
Please consider this