rxr
rxr copied to clipboard
Ability to return null
A common issue I've run into with RxR reducers is accessing state. The reducers must return state, but in some workflows a reducer is going to call other reducers. For example, here in fetchClientsReducer$.
If you nest the reducer calls in the curried function, then the state modifications made by those calls will be wiped when you return the old state:
(something) => (state) => {
//Call another reducer:
actionStreams.commonReducer$.next({...state.something, ...something});
// Returning this state will now undo the changes made by commonReducer
return state;
}
You can do:
(something) => {
actionStreams.commonReducer$.next({...state.something, ...something});
return (state) => state;
}
But then you don't have access to state.
I think reducers should have the option to return nothing or return undefined, and RxR should know the reducer doesn't modify state.
(something) => (state) => {
//Call another reducer:
actionStreams.commonReducer$.next({...state.something, ...something});
}
When I try this now, my state object is wiped.