Simplified effect cancellation for a subview #891
surajbarkale
started this conversation in
Show and tell
Replies: 1 comment 3 replies
-
Hi @surajbarkale! I tried to do it this way too, but it didn't fit some of my use cases.
Please check out Swift Composable Presentation library. Could you provide more details about what problems did you experience when using deeply nested states (e.g. Tagged)? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
There is already a lot of discussion around how to handle effect cancellation when a view is dismissed. @darrarski has kindly created a summary of all approaches. The minimum effort implementation is the
.presents()
extension onReducer
.However, I have found the
.presents()
function hard to compose when using deeply nested states (e.g. Tagged). So I have updated it as an overload on.optional()
:With this extension, simply changing
.optional()
to.optional(cancelEffectsOnNil: true)
will cancel all effects of the child state when it becomes nil.Beta Was this translation helpful? Give feedback.
All reactions