Hi! I'm summoning this issue from the grave. So sorry ![]()
The context:
So the solution described above works fine if there is not much of composition. TCA is composable and that's what we want to embrace. My issue is how we can deal with optional reducers which have non-optional reducers.
I have published a fork of darraski's repo here GitHub - hfossli-agens/tca-ifletstore-effect-cancellation-demo at nested-views-problem
Basically the state tree is
AppState
|--> DetailState?
|--> time: Date
|--> me: AvatarState
|--> peer: AvatarState
The AvatarView wants to cancel any ongoing requests on onDisappear.
The problem
The current code examples for lifecycle is only directly applicable to optional reducers with no levels of view composition. E.g. my AvatarView inside DetailView crashes the reducer if it sends onDisappear actions because the state is nilled.
What I have tried:
I have had a bit of a hard time finding the best solution for this problem.
Notes:
The main goal is to cancel the ongoing effect. Note that one AvatarView shouldn't interfere with other AvatarViews. Using shared cancellation-ids between AvatarViews is a no-go. The AvatarView might be visible other places. We are passing the cancellation-id to the AvatarView via AvatarEnvironment. If we only had access to the environment via the ViewStore we could actually cancel without reducing.
Anyone else share my concerns and face similar problems?