Last active
March 17, 2017 00:11
-
-
Save oieduardorabelo/99bce3503b20419e41d58df3f6d878d8 to your computer and use it in GitHub Desktop.
Signals and Actions helper for Redux/Redux-Saga
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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