Observable Architecture: Observing Navigation

Episode #264 • Jan 15, 2024 • Subscriber-Only

Observation has allowed us to get rid of a number of view wrappers the Composable Architecture used to require in favor of vanilla SwiftUI views, instead, but we still depend on a zoo of view modifiers to drive navigation. Let’s rethink all of these helpers and see if we can trade them out for simpler, vanilla SwiftUI view modifiers, instead.

Previous episode
Observable Architecture: Observing Navigation
Next episode
Locked

Unlock This Episode

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

Sign in with GitHub

Introduction

Brandon

By getting rid of our specialized view helper, the ForEachStore, we have unlocked all new super powers for when modeling lists of features in the Composable Architecture. We get to use all of the fancy collection APIs that come with the standard library in order to slice and dice a collection of data for display in the UI, and everything is still rendered in the most minimal way possible.

So, we have now gotten rid of the WithViewStore, IfLetStore, SwitchStore, CaseLet and ForEachStore. Those were the only dedicated views that the library shipped in order to deal with optional state, enum state, and collection state.

Stephen

But there’s another class of helpers that ship with the library that are also no longer needed in the world of Swift observation, and that’s navigation view modifiers. We currently have to maintain a whole zoo of view modifiers that mimic ones that come with vanilla SwiftUI but tuned specifically for the Composable Architecture. This includes modifiers for sheets, popovers, fullscreen covers, drill-downs, navigation stacks, and more.

Well, amazingly, we can stop using all of those helpers and instead just use the vanilla SwiftUI view modifiers. And it’s all thanks to the observation tools in Swift.

Let’s take a look.

Navigation: a recap and rethink


Get started with our free plan

Our free plan includes 1 subscriber-only episode of your choice, access to 64 free episodes with transcripts and code samples, and weekly updates from our newsletter.

View plans and pricing