Closed
Description
I was little annoyed by string constants as action types. And write solution for this, need for objective criticism and ideas. The solution is create action as class methods, and make method name accesible.
@EasyActions
class Actions {
USER_ACTION(type, id){
return {type, id}
}
}
export default new Actions();
---
import Action from './actions';
dispatch(Actions.USER_ACTION(42))
switch(action.type) {
case Actions.USER_ACTION:
// return state
}
More info and examples here: https://github.com/grigory-leonenko/redux-easy-actions