Skip to content

Instantly share code, notes, and snippets.

@jtulk
Created July 13, 2017 06:41
Show Gist options
  • Save jtulk/41233fcf15136d8b154e93d620aaa836 to your computer and use it in GitHub Desktop.
Save jtulk/41233fcf15136d8b154e93d620aaa836 to your computer and use it in GitHub Desktop.
import { ACTIONS } from './actions';
// Log if a fetch is aborted by the async call running too aggressively.
export const abortFetch = () => ({
type: ACTIONS.abort
});
/**
* Log an error if the async call fails
* @param {object} error - the error thrown.
*/
export const errorFetch = error => ({
type: ACTIONS.error,
error
});
// Start the fetch, toggle is `isFetching` value
export const startFetch = () => ({
type: ACTIONS.start
});
/**
* Resolve the fetch with the returned data
* @param {object} payload - the data returned from the fetch
*/
export const updateFetch = payload => ({
type: ACTIONS.update,
payload
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment