Last active
November 20, 2017 14:04
-
-
Save unel/278739942a298d240d8522596dd231fb to your computer and use it in GitHub Desktop.
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 default function asyncReducer(state = isLoading, { type, payload }) { | |
switch (type) { | |
case AJAX_CALL_BEGIN: | |
if (payload === 'comments') { | |
return { ...state, comments: 1 }; | |
} | |
return { ...state, product: 1 }; | |
case AJAX_CALL_SUCCESS: | |
if (payload === 'comments') { | |
return { ...state, comments: 0 }; | |
} | |
return { ...state, product: 0 }; | |
case AJAX_CALL_ERROR: | |
if (payload.target === 'comments') { | |
return { ...state, comments: 0, error: payload.eror }; | |
} | |
return { ...state, product: 0, error: payload.error }; | |
default: | |
return state; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment