Imagine a case where I needed to increment by [1, 5, 10, 20, 30, 50, 100, 200, 1000]; are you gonna have actions and types for every one of these? Of course not, you're gonna make a function incrementByN which accepts any number, and then only pass the values [5,10,15] to the function.
This is the specific case in your application. The general rule is that you want your components/functions/logic in general to be most general in its specificity. Meaning that your logic should handle a whole domain of specific cases, not just one, a function that handles only one singular case shouldn't be a function in the first place.
https://github.com/AhmedYahya24/spzceX/blob/d753e7f6e31fa36501ca331d113bc0521a555a4d/space-x-graphql/src/utils/redux/actions/limitAction.js#L1-L17
Imagine a case where I needed to increment by
[1, 5, 10, 20, 30, 50, 100, 200, 1000]
; are you gonna have actions and types for every one of these? Of course not, you're gonna make a functionincrementByN
which accepts any number, and then only pass the values[5,10,15]
to the function.This is the specific case in your application. The general rule is that you want your components/functions/logic in general to be most general in its specificity. Meaning that your logic should handle a whole domain of specific cases, not just one, a function that handles only one singular case shouldn't be a function in the first place.