Last active
September 18, 2018 11:36
-
-
Save gastonmorixe/cf6f40578524ddd085dd to your computer and use it in GitHub Desktop.
Redux React CombineReducers Discussion [With Dan Abramov]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { combineReducers } from 'redux' | |
import reduceReducers from 'reduce-reducers' | |
import { invites } from './Invites' | |
import { claimInvite } from './ClaimInvite' | |
import { app } from './App' | |
import * as actions from '../constants/ActionTypes' | |
import {mapping, parseRemotePersonJSON} from './App' | |
const combinedReducer = combineReducers({ | |
invites, | |
app, | |
claimInvite, | |
}) | |
const rootAccessReducer = (state, action) => { | |
switch (action.type) { | |
case `${actions.REQUEST_INVITE}_FULFILLED`: | |
return { ...state, | |
app:{...state.app, | |
loggedPerson: {...state.app.loggedPerson, | |
...parseRemotePersonJSON(action.payload.person), | |
authToken: state.app.loggedPerson.authToken | |
} | |
}, | |
claimInvite:{...state.claimInvite, | |
inviteRequest: {...state.claimInvite.inviteRequest, | |
state: 'loaded' | |
} | |
} | |
} | |
default: | |
return state | |
} | |
} | |
const rootReducer = reduceReducers(combinedReducer, rootAccessReducer) | |
export default rootReducer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@imton,
I'm currently in the boat you were in during the time of this gist. I was hoping you could help shed some light. How did you handle higher order components/reducers that depended on other primitive reducers and do so with async fetch calls? Did redux-promise-middleware/redux-saga seem end up feeling like a good fit?