-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancers are added after middleware #39
Comments
Out of curiosity, what other enhancers do you have that are generating actions? |
Hmm. Okay, so yeah, looking at the My first instinct is that the point of |
This is the only one for me it is not a problem to write few lines of code that never change. I just wanted to point that out for consideration. |
My company's also using Do any other projects break if enhancers come first? |
If we wanted to support this, here is an idea: Export a special import { configureStore, configureMiddleware } from 'redux-starter-kit'
configureStore({
reducer,
// enhancer comes after middleware, as before
store: [enhancer]
})
configureStore({
reducer,
// middleware comes after enhancer
store: [enhancer, configureMiddleware]
})
configureStore({
reducer,
// middleware comes after enhancer1, before enhancer2
store: [enhancer1, configureMiddleware, enhancer2]
}) |
I suppose that's a possibility. Could accept a PR that adds that. |
Just a thought. This looks worse then original config. Why not let the possibility to just configure store as you would in redux normally. For "advanced" uses. |
@primozs : if you want to configure the store "normally", there's nothing stopping you from using |
@markerikson I got confused when I saw only some parts of redux re exported. |
The same problem happens with the enhancer of the I created a ticker for that one: #184 |
I'm not particularly sold on the "magic |
Hmm. We currently have https://redux-starter-kit.js.org/api/getDefaultMiddleware . Maybe we need a |
What about accepting a callback as function configureStore({
// A single reducer function that will be used as the root reducer,
// or an object of slice reducers that will be passed to combineReducers()
reducer: Object<string, ReducerFunction> | ReducerFunction,
// An array of Redux middlewares. If not supplied, uses getDefaultMiddleware()
middleware?: MiddlewareFunction[],
// Enable support for the Redux DevTools Extension. Defaults to true.
devTools?: boolean | EnhancerOptions,
// Same as current createStore.
preloadedState?: State,
// An optional array of Redux store enhancers
enhancers?: ReduxStoreEnhancer[] | (defaultEnhancer: ReduxStoreEnhancer) => ReduxStoreEnhancer[],
}) |
Mmm... not sure I like the callback idea either. I'm definitely leaning towards |
But wouldn't the So you'd have to pass in the middlewares and end up with something like this:
Having to pass in the middlewares at two different places would make it impossible to write the middlewares inline. |
Hmm. Excellent point. Okay, I see what you're getting at with the callback thing. In that case, would it make sense to do that for both middleware and enhancers, and drop We're still 0.x, so we're semantically allowed to make whatever breaking changes we want, but I'd obviously like to minimize churn overall. FWIW, I see a number of folks calling https://github.com/search?l=JavaScript&q=getdefaultmiddleware&type=Code |
Either that, or enable both the current behaviour and the callback option. That might have not been clear from my initial post: Similarly, |
Resolved this by adding the callback idea for |
Hello,
Could the order of enhancers be switched? Now they are added after the middleware and that is why no middleware can see actions that are generated by enhancers.
Combination of redux-first-router and redux-saga is an example of this.
The text was updated successfully, but these errors were encountered: