You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
taskAdd=(name)=>({name: 'TASK_ADD',data: {
name
}});taskDone=(id)=>({name: 'TASK_DONE',data: {
id
}});
It suffers from these problems:
Repetitive typing where you repeat name and data for each action and then also repeat the list of parameters, twice for each action.
Action names are not defined as reusable/importable constants (therefore you can't enforce compile-time checks on them).
(Minor) For some reason you're not using const but instead let the variables at top of the file. I guess it's some legacy/habit issue?
Have you given any thought on these problems before? I like the CRC/CCA approach in general but applying it directly means sacrificing the above. For example, with redux-actions I can:
// Identity action creator, no boilerplate at all, clean and DRY.exportconstchatMessageSent=createAction('CHAT_MESSAGE_SENT');
but a proper well-thought library when you still can override the action creator logic, specify list of fields etc. would be better.
And then again, in redux-immutable you need to use these ALL_CAPS constants (which you can't import!) as the key names in reducers, while in redux-actions they provide a handy shortcut with compile-time check (something your combineReducers could also benefit from):
Here's the current actions boilerplate:
It suffers from these problems:
name
anddata
for each action and then also repeat the list of parameters, twice for each action.const
but insteadlet
the variables at top of the file. I guess it's some legacy/habit issue?Have you given any thought on these problems before? I like the CRC/CCA approach in general but applying it directly means sacrificing the above. For example, with
redux-actions
I can:and then (in a redux saga):
and I get no headache about possible typos in the action names.
Of course I can come up with a poor man ad-hoc shortcut, something like:
but a proper well-thought library when you still can override the action creator logic, specify list of fields etc. would be better.
And then again, in
redux-immutable
you need to use these ALL_CAPS constants (which you can't import!) as the key names in reducers, while inredux-actions
they provide a handy shortcut with compile-time check (something yourcombineReducers
could also benefit from):I know this is not a proper ticket and more of a rant, but anyway. 🙃
The text was updated successfully, but these errors were encountered: