Replies: 1 comment 1 reply
-
Hey @rcarver, thanks for sharing! These are handy tools to have, and we have made use of some adhoc versions of these in our own work too. Also, our upcoming navigation tools will bake a lot of this logic directly into the APIs so you won't even have to think about cancellation. We hope to have some stuff to share soon. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The new Task-based effect lifecycle is amazing, it solves so many issues with presentation of optional state. There's a few scenarios that still felt awkward so wanted share an idea (or maybe there's already a way to do this?)
By using this pattern to tie long-living effects to the life of the view, any effects returned by the
.task
action are cancelled automatically:But sometimes you need to do other things when the view disappears:
.task
action but still needs to be cancelled.These methods on Effect seem to do the trick:
Here's an example of using
cancelling(id:)
Here's an example of using
.finish
. The eyedropper feature is managed in the environment to coordinate among several components. When the view appears we show it if the state tells us to. When the view disappears we always hide it.Beta Was this translation helpful? Give feedback.
All reactions