Case Paths

Section • 3 episodes • 1 hr 29 min

Key paths are an incredibly powerful feature of the Swift language: they are compiler-generated bundles of getter-setter pairs and are automatically made available for every struct property. So what happens when we theorize an equivalent feature for every enum case?

Related content

Let’s apply case paths to a real-world use case: application architecture! We’ll use case paths to refactor one of the most important operations of our composable architecture.

Composing Architecture with Case Paths
22 min

Where to go from here

Next we will explore a real-world use for case paths: SwiftUI and the Binding type. Bindings are the fundamental unit that connects your data model to your UI, but one of its core operators for transformation rely on key paths, thus restricting our domain modeling to structs. We will fix this disparity by beefing up the Binding type with support for case paths.