So, we think it’s pretty incredible how easy it is to add new features to an existing navigation stack. It only took about 3 steps: you add the feature’s domain to the Path
reducer, you add a scope to the Path
reducer’s body, and finally you add the view to the NavigationStackStore
’s destination closure.
And once you complete those few steps you get immediate and infinite introspection into everything that is happening in the feature when it is on the stack. This includes being able to traverse and aggregate data across the elements of the stack, and the ability to see every single action sent into the child feature.
But, as amazing as this all seems, there are some serious problems lurking in the shadows, and they are reminiscent of what we experienced with our presentations APIs for sheets, popovers and covers.
One of the big problems we saw with those forms of navigation, and in particular the ifLet
operator, is that when the child feature was dismissed, its effects were not cancelled. That allowed effects to continue feeding data into the system even long after the child feature had gone away.
This problem also exists in our navigation stack, and the forEach
operator, so let’s see how it can happen and what it takes to fix it.