Skip to content

Instantly share code, notes, and snippets.

@Tauka
Last active April 16, 2017 00:29
Show Gist options
  • Select an option

  • Save Tauka/4783d7c2384578a09a90a7f129e5cc2f to your computer and use it in GitHub Desktop.

Select an option

Save Tauka/4783d7c2384578a09a90a7f129e5cc2f to your computer and use it in GitHub Desktop.
export function typicalAction(loadingCb, successCb, failCb) {
return function(dispatch) {
loadingCb();
fetch(`http://someapi/user`)
.then((response) => {
dispatch({type: "ACTION_SUCCESS", payload: response});
successCb();
})
.catch((err) => {
failCb();
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment