Navigation with TCA Optional Child State #1712
Unanswered
lightandshadow68
asked this question in
Q&A
Replies: 0 comments
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.
-
I'm working on an app that includes a list and detail screen. Each has their own feature that conforms to ReducerProtocol and the detail state is a child of the list state. The detail screen is "live", in that at receives a series of updates for the selected item in the list using an async sequence from an ItemClient dependency. This is initialized from the detail screen via an .onAppear action and sends a .itemUpdated action when live changes are detected. Currently, I have a working example, modeled off the "03-Navigation-Lists-LoadThenNavigate" example. This ensures the list's child state is nil until an item is selected and vice versa.
However, based on the app's requirements. it's not necessary to do any other work before navigating to the detail screen, beyond setting and nilling out the detail feature child state in the list feature state and updating a selected property.
Is there some simpler way to do this? Or is the work of setting and clearing the child state essentially "loading" work in preparation for navigation, and that's the currently recommended means to achieve it?
Preferably, there would be some way to set the child state as part of the NavigationLink selection to non-nil and trigger navigation.
Beta Was this translation helpful? Give feedback.
All reactions