Skip to content

Instantly share code, notes, and snippets.

@dewey92
Last active July 30, 2019 02:44
Show Gist options
  • Select an option

  • Save dewey92/4f58c62287968e19bb953caa49184c0d to your computer and use it in GitHub Desktop.

Select an option

Save dewey92/4f58c62287968e19bb953caa49184c0d to your computer and use it in GitHub Desktop.
Invalidate the invalids
export const AsyncState = { // <- HERE
initial: 'initial',
fetching: 'fetching',
success: 'success',
error: 'error'
}
const initialState = {
asyncState: AsyncState.initial,
};
export default (state = initialState, action) => {
switch(action.type) {
case 'GET_XXX_REQUEST':
return {
...state,
asyncState: AsyncState.fetching // <- Here
}
case 'GET_XXX_SUCCESS':
return {
...state,
asyncState: AsyncState.success // <- Here
}
case 'GET_XXX_FAILED':
return {
...state,
asyncState: AsyncState.error // <- Here
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment