redux-router5-immutable
Closed this issue · 2 comments
Hello, I am using router5 on a current project where we use immutablejs to store the state.
I was about to write a immutablejs compatible reducer (which is just a rewrite of router5reducer using immutablejs).
Do you think I should make a pull request to this repository (with a filename like router5ImmutableReducer) or create a distinct npm package redux-router5-immutable.
I am more in favor to add it to this repository as the code will be mostly the same as the regular reducer and so it will be easier to maintain.
What do you think ?
Edit:
A con to the first solution: this will add a direct dependency to immutablejs to this repo :/
Here what I am using right now
https://gist.github.com/Nihaux/578bd6d0654db97a578b284726a063b5#file-router5immutablereducer-js
- in file routeNodeSelector
var routerStateSelector = function routerStateSelector(state) {
return state[reducerKey] || state.get(reducerKey);
};
This could be included in the repo. I have refactored and released 4.1.0 for that purpose. If you're up to create a PR:
- Add immutablejs as a peer and dev dependency, but not as a dependency
- To be safe in routeNodeSelector:
return state[reducerKey] || (state.get && state.get(reducerKey));
- Create a file for your gist, don't import it in
modules/index.js
. Not sure how you can name it, don't hesitate to create a directory for it. Maybe something likeimport router5Reducer from 'redux-router5/immutablejs/reducer'
would look good?