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.

Observing Navigation
Introduction
00:05
Navigation: a recap and rethink
01:20
Scoping store bindings
09:38
Next time: Observing bindings
20:38

Unlock This Episode

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

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.

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