RFC: Remove public-facing reduce
requirement from Reducer
#2102
Replies: 6 comments 7 replies
-
As someone who loves premature optimization and pedantic rules, I'll miss it, but I think the wins in consistency and similarity to |
Beta Was this translation helpful? Give feedback.
-
I'm all-in for the change! That being said, Footnotes
|
Beta Was this translation helpful? Give feedback.
-
I consistently utilise |
Beta Was this translation helpful? Give feedback.
-
I've been bit by the issue where providing both the current reduce method and the body property at the same time causes undesired behavior, so removing it in favor of one true way of making a reducer sounds good to me as a way of removing that potential strange issue from happening again! |
Beta Was this translation helpful? Give feedback.
-
Great change! I've always struggled to explain the difference between the two styles of creating a One question though, When declaring |
Beta Was this translation helpful? Give feedback.
-
This is great, consistency is key, especially when you're learning like myself. |
Beta Was this translation helpful? Give feedback.
-
Hi all!
We’d like to make a pretty substantial change to the Composable Architecture, and that is to remove the public-facing
reduce
method requirement of theReducer
protocol. Instead, we’d like to encourage that folks always use thebody
property as the single way of conforming to the reducer protocol:We have found that most people tend to start new reducers with the body property anyway since the vast majority of time you will eventually compose more reducers into your reducer.
Pros:
reduce
or think about when to use it vs.body
with aReduce
.reduce
tobody
.Cons:
Reduce
may incur a small performance penalty. We don’t think it will be measurable in most applications, as the closures do not actually escape thebody
of most reducer conformances. This probably will not actually affect many people since as we mentioned above, most people seem to use the body style of reducer anyway.Reduce
closures vs. thereduce
method, and in some earlier versions of Swift, explicit generics (Reduce<State, Action>
) are required to restore diagnostics and autocomplete. Recent versions of Swift, however, have mitigated many of these problems.We plan on starting to make these changes soon, but we wanted to communicate to users of the Composable Architecture to give them time to ask any questions, and communicate any feedback or concerns.
Please let us know what you think!
Beta Was this translation helpful? Give feedback.
All reactions