Breaking change on ifLet
reducer in 0.54.0
#2162
Replies: 2 comments 1 reply
-
Hi @AndreaRomani, while the behavior of Can you show us a more real world example of how this problem crops up? It's also worth mentioning that the effect cancellation behavior of |
Beta Was this translation helpful? Give feedback.
-
I'm going to convert this to a discussion since it is not something we will consider changing right now, but we would love to hear more about the problem if it is really significant. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
I found a possible regression/breaking change in release
0.54.0
when using the.ifLet
operator with nonPresentationState
.The new
_IfLetReducer
has a different implementation from before, even for nonPresentationState
. In particular it does access child state even when handling a non child action, whereas all the child logic used to be short-circuited in previous releases.As far as I understood, the reason why child state is accessed (here) is to allow child effects to be cancelled. I believe this is too strong of an assumption to make: there may be cases in which we don't use the operator for, strictly speaking, presentation purposes, or we may not be interested in effects cancellation at all because the child feature doesn't even start effects, or they are just
.fireAndForget
.As an example of why this is a breaking change, the following code runs just fine on previous releases (I tested it on
0.52.0
), but hits a crash on0.54.0
. I would expect:.ifLet
to restore the previous behaviour opting out from effect cancellation checksI haven't found previous discussions on this matter, feel free to redirect me there in case this behaviour is intended. Maybe there's already a fix I'm not aware of 🙂
p.s. thanks for the amazing work you did with this navigation series 🚀 looking forward to unlock the full potential from these tools 🚀
Checklist
main
branch of this package.Expected behavior
The example test shouldn't crash
Actual behavior
_IfLetReducer
accesses child state even for non child action, opening the possibility for new crashesSteps to reproduce
Copy the sample code and run the test
The Composable Architecture version information
0.54
Destination operating system
iOS 16
Xcode version information
Xcode 14.3.1
Swift Compiler version information
Beta Was this translation helpful? Give feedback.
All reactions