Reputation: 2162
I'm using react-loop, and I'm trying to use its combineReducers but extend it to pass as a third parameter the global state, basically implementing an API similar to https://github.com/Velenir/combine-reducers-global-state
Combine reducers basically invokes the childReducers as we can find in its code
let currentChild = childReducer(prev[key], action, ...args);
The idea is to pass there a third parameter, so , action, plainState, ...args
so that the reducer receive it as parameter. The problem is how to produce that plainState, since the rootState is basically a combination of array of the form ([state, Cmd]) instead I need only the plain state, without redux-loop handler variables.
Upvotes: 1
Views: 149
Reputation: 1745
You'd have to write your own version of combineReducers. The supplied one is not expected to work outside of the simplest case. You can base it off of the supplied one though. https://github.com/redux-loop/redux-loop/blob/master/src/combine-reducers.js. I imagine you can implement it similarly to the library you mentioned.
If you're looking for a way to inject other state values into a reducer though, check out this middleware that I've used with redux-loop for a few years now. https://github.com/bdwain/redux-action-enhancer
Disclaimer: I maintain both redux-loop and redux-action-enhancers.
Upvotes: 1