Skip to content

Instantly share code, notes, and snippets.

@selbekk
Created February 5, 2018 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save selbekk/2baf95672117808167d6db6233a73232 to your computer and use it in GitHub Desktop.
Save selbekk/2baf95672117808167d6db6233a73232 to your computer and use it in GitHub Desktop.
Action creator creators!
import Case from 'case';
export const createAction = name => ({
[Case.constant(name)]: Case.constant(name),
[Case.camel(name)]: payload => ({
type: Case.constant(name),
payload,
}),
});
export const createNetworkAction = name => ({
...createAction(`${name}Requested`),
...createAction(`${name}Received`),
...createAction(`${name}Failed`),
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment