-
-
Save indigoviolet/b117754dcc8eaea5f6e2e6a3a6fc3c24 to your computer and use it in GitHub Desktop.
fin blog embed
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
export const createAsyncReducer = (type, reducers = {}) => { | |
let defaultReducers = { | |
loading: (state = false, action) => { | |
if (action.type === type) { | |
return action.readyState === REQUEST; | |
} | |
return state; | |
}, | |
data: (state = null, action) => { | |
if (action.type === type) { | |
return action.data; | |
} | |
return state; | |
}, | |
error: (state = null, action) => { | |
if (action.type === type) { | |
return action.error; | |
} | |
return state; | |
}, | |
}; | |
return combineReducers(Object.assign({}, defaultReducers, reducers)); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment