Skip to content

Instantly share code, notes, and snippets.

@unel
Created November 20, 2017 14:04
Show Gist options
  • Save unel/627a2aef29a292dbcb8e99440f490658 to your computer and use it in GitHub Desktop.
Save unel/627a2aef29a292dbcb8e99440f490658 to your computer and use it in GitHub Desktop.
export default function asyncReducer(state = isLoading, { type, payload }) {
switch (type) {
case AJAX_CALL_BEGIN:
return { ...state, [payload]: 1};
case AJAX_CALL_SUCCESS:
return { ...state, [payload]: 0};
case AJAX_CALL_ERROR:
return { ...state, [payload.target]: 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