Skip to content

Instantly share code, notes, and snippets.

@oieduardorabelo
Last active March 17, 2017 00:11
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 oieduardorabelo/99bce3503b20419e41d58df3f6d878d8 to your computer and use it in GitHub Desktop.
Save oieduardorabelo/99bce3503b20419e41d58df3f6d878d8 to your computer and use it in GitHub Desktop.
Signals and Actions helper for Redux/Redux-Saga
// We can replace here by `redux-actions`
const createActionCreator = function(action) {
return function(data) {
return {
type: action,
payload: data,
}
}
}
export const createSignalAction = function(reducerName, base) {
return ['REQUEST', 'SUCCESS', 'FAILURE'].reduce((prev, curr, index) => {
prev[curr] = `SIGNAL/${reducerName}/${base}/${curr}`;
prev[curr.toLowerCase()] = createActionCreator(prev[curr]);
return prev;
}, {})
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment