Not getting expected parent domain state mutations when implementing stack based navigation #2579
-
I'm attempting to learn/ use TCA while writing my son a side project app to help him practice reading. I am either misunderstanding something or implementing something wrong (or both!). I'm following along with episode 246 but things start to become unexpected (to me) once I compose child reducers with the path reducer. In constructing a Story domain, where a user can customize a story and then read it after, I have the following:
I've implemented state as an enum as you're either creating a story or reading one, but never both at the same time. I can see the argument for having create and read as separate domains/ screens but I still want to figure this out. The create story domain consists of a series of smaller sub-features (as I like to think of them) and looks something like this:
The path reducer looks like:
The root view of the story domain looks like this:
And the root view of the create story domain looks like this:
I use navigation links in each of the sub-feature/ domain views to drive navigation/ path state changes like in the video. I'm monitoring the parent reducer with printChanges and I've written a few tests and what I'm noticing is that whenever I perform an action in the
but this test passes:
I must not be understanding something when composing the higher order reducer with path and friends. This was a long post, any tips or insight or timestamps in relevant episodes are greatly appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 10 replies
-
Hi @catienza022, can you share a minimal project that demonstrates the behavior you are seeing? |
Beta Was this translation helpful? Give feedback.
Alright, I may have figured it out. On episode 246 at about the 31 minute mark you mention that the features aren't actually completely integrated together at this point. We need a way for children to let the parent know that data has updated by pattern matching on path actions (or the nested delegate action pattern). In your video example you popFrom and update at that point. I missed this because I don't need to update parent data on popping, but rather pushing/ navigating from the last screen of the flow.