reactrails-react-native-client
reactrails-react-native-client copied to clipboard
Reduce action creator boilerplate
Should we introduce an utils to reduce boilerplate for action creators?
function makeActionCreator(type, ...argNames) {
return function(...args) {
let action = { type }
argNames.forEach((arg, index) => {
action[argNames[index]] = args[index]
})
return action
}
}
Source: http://redux.js.org/docs/recipes/ReducingBoilerplate.html
IMHO, definitely worth considering.
There are also utility libraries to aid in generating action creators, such as redux-act and redux-actions. These can help reduce boilerplate code and enforce adherence to standards such as Flux Standard Action (FSA).
CC: @robwise @alexfedoseev
I agree, I've always wanted to try this. You could also check out some of the libraries out there:
- https://github.com/pauldijou/redux-act
- https://github.com/acdlite/redux-actions
There is also a standard called Flux Standard Action (FSA)