🎉 Black Friday Sale! Save 30% when you subscribe today.
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?
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.
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.