Composable Stacks: Effect Cancellation

Episode #236 • May 22, 2023 • Subscriber-Only

We round out the functionality of the Composable Architecture’s stack navigation tools. This includes automatic cancellation of a child feature’s effects when it’s popped off the stack, and the ability for a child feature to pop itself. Along the way we will clean up the domain modeling and user experience of working with these tools.

Effect Cancellation
Introduction
00:05
Automatic effect cancellation
01:41
Child-driven dismissal
09:38
A more precise StackAction
20:22
Fixing a child dismissal bug
32:18
Next time: testing stack navigation
36:47

Unlock This Episode

Our Free plan includes 1 subscriber-only episode of your choice, plus weekly updates from our newsletter.

Introduction

Brandon: 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.

Stephen: 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.

This episode is for subscribers only.

Subscribe to Point-Free

Access this episode, plus all past and future episodes when you become a subscriber.

See plans and pricing

Already a subscriber? Log in

References

Composable navigation beta GitHub discussion

Brandon Williams & Stephen Celis • Monday Feb 27, 2023

In conjunction with the release of episode #224 we also released a beta preview of the navigation tools coming to the Composable Architecture.