You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 15, 2018. It is now read-only.
Hi, thanks for the redux-little-router, it's great!
I'm trying out if redux-little-router could be used in project i'm working on. The problem is that in order to be able to have side effects on redux-little-router actions in middlewares, the enhancer needs to be the first one in the enhancer chain. Some libraries have strong opinions about this. For example ngRedux don't allow having any enhancers before middlewares: https://github.com/angular-redux/ng-redux . Also redux documentation recommends against having other enhancers before middlewares which makes the decision of ngRedux understandable as it just follows the best practices from redux docs: http://redux.js.org/docs/api/applyMiddleware.html#tips
When i looked into code, I saw that the enhancer only adds one function, matchRoute into store, which actually is not used anywhere. When removing matchRoute, the enhancer doesn't anymore enhance the store; It just connects to it and uses it. If the enhancer does not enhance the store in any way, it shouldn't be in enhancer chain in the first place. Instead I suggest to change the enhancer to less magical connect -function where you pass the store in. I think this would actually also convey the meaning of the enhancer better, as it's purpose is to connect the router into redux store. It also makes the enhancer code slightly simpler. What do you think?
Since the router would connect to ready made store, it would eliminate the risk that middlewares wouldn't capture actions dispatched by the router.
I also wrote a PR to demonstrate what I mean: #216
The text was updated successfully, but these errors were encountered:
Hi, thanks for the redux-little-router, it's great!
I'm trying out if redux-little-router could be used in project i'm working on. The problem is that in order to be able to have side effects on redux-little-router actions in middlewares, the enhancer needs to be the first one in the enhancer chain. Some libraries have strong opinions about this. For example ngRedux don't allow having any enhancers before middlewares: https://github.com/angular-redux/ng-redux . Also redux documentation recommends against having other enhancers before middlewares which makes the decision of ngRedux understandable as it just follows the best practices from redux docs: http://redux.js.org/docs/api/applyMiddleware.html#tips
When i looked into code, I saw that the enhancer only adds one function,
matchRoute
into store, which actually is not used anywhere. When removing matchRoute, the enhancer doesn't anymore enhance the store; It just connects to it and uses it. If the enhancer does not enhance the store in any way, it shouldn't be in enhancer chain in the first place. Instead I suggest to change the enhancer to less magical connect -function where you pass the store in. I think this would actually also convey the meaning of the enhancer better, as it's purpose is to connect the router into redux store. It also makes the enhancer code slightly simpler. What do you think?Since the router would connect to ready made store, it would eliminate the risk that middlewares wouldn't capture actions dispatched by the router.
I also wrote a PR to demonstrate what I mean: #216
The text was updated successfully, but these errors were encountered: