-
-
Couldn't load subscription status.
- Fork 15.2k
Closed
Description
I would like to know if it would be possible to receive, as a parameter in a reducer, an arrow function instead of an action, so the switch can be omitted and it would be only necesary to execute the mentioned function.
If this were possible, switch cases could be avoided, resulting in improved performance of reducers with many different actions.
Example:
Before:
function reducer(previousState, action) {
switch(action.type) {
case 'ACTION1':
return { ..1.. };
case 'ACTION2':
return { ..2.. };
case 'ACTION3':
return { ..3.. };
}
}
After:
action1(previousState) => { ..1.. }
action2(previousState) => { ..2.. }
action3(previousState) => { ..3.. }
function reducer(previousState, arrowFunction) {
return arrowFunction(previousState);
}
Metadata
Metadata
Assignees
Labels
No labels