-
Hello :) In our app, when the user is deep-linked into some scene, some of the intermediate scenes as well as the top-most scene (the final destination, so to speak) may have subscriptions to async data and other resources that need to be properly disposed of when those scenes are dismissed. If/when the app receives a new deep-link request, is it sufficient to set the destination at the root to nil, wait for all the intermediate scenes to be dismissed, and then set a new destination? Or do we have to manually traverse the scene hierarchy to clean up each scene and then traverse back to the root, before setting the new destination? More generally, in a situation like this (changing one scene hierarchy into another) where scenes may have long-running effects, what's the TCA-recommended way to go about it? Thanks in advance for any help. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @wtruppel, are you using the new presentation tools such as However, I will also say that SwiftUI (and sometimes, but less often, UIKit) has a problem with dismissing long chains of presentation all at once. In practice you may find that you have to dismiss in a multi-step process. Just something to be aware of in case you see strange behavior. |
Beta Was this translation helpful? Give feedback.
-
Hi @mbrandonw, thanks for answering. Yes, we're using the new presentation tools. We're having a lot of issues with deep-linking and I just wanted to make sure they're due to SwiftUI and not to TCA. Your answer was what I was expecting but I just wanted to make sure. Thanks again. |
Beta Was this translation helpful? Give feedback.
Hi @wtruppel, are you using the new presentation tools such as
@PresentationState
andifLet
? If so, then effects from child features are automatically cancelled when the feature is dismissed. This works even if there is a presentation chain of childA>childB>childC and you dismiss childA. The effects for childB and childC will be cancelled.However, I will also say that SwiftUI (and sometimes, but less often, UIKit) has a problem with dismissing long chains of presentation all at once. In practice you may find that you have to dismiss in a multi-step process. Just something to be aware of in case you see strange behavior.