Skip to content

Instantly share code, notes, and snippets.

@neurosnap
Created November 19, 2016 03:39
Show Gist options
  • Save neurosnap/78648b2e86e1fa8e1e274369f75e86b6 to your computer and use it in GitHub Desktop.
Save neurosnap/78648b2e86e1fa8e1e274369f75e86b6 to your computer and use it in GitHub Desktop.
Simple action creator
// actionCreator.js
export default (type: string) => (payload: Object) => ({ type, payload });
// Examples
export const FETCH_THREADS = 'threadFetch/FETCH';
export const fetchThreads = actionCreator(FETCH_THREADS);
export const FETCH_NEXT_PAGE = 'threadFetch/FETCH_NEXT_PAGE';
export const fetchNextPage = actionCreator(FETCH_NEXT_PAGE);
export const ADD_THREADS_DOWNLOADED = 'threadFetch/ADD_THREADS_DOWNLOADED';
export const addThreadsDownloaded = actionCreator(ADD_THREADS_DOWNLOADED);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment