🎉 Black Friday Sale! Save 30% when you subscribe today.
One of the fundamental units of SwiftUI state management is the Binding type, which connects your data model to your UI. It even comes with composable, transformable operations that make it really nice to use…with structs. Enums, unfortunately, are completely left out of the equation, which can lead us to model our domains in less than ideal ways. We will dissect the problem and build the tools that Apple leaves out of the framework.
The Binding
type is just one of many examples of Swift and its frameworks providing special treatment to structs while leaving enums behind, but structs are no more important than enums. In fact they are two sides of the same coin, both equally important in their own way. In this collection we explore more of these disparities and attempt to bridge the gaps.
Our search for a transformation operator on Binding
is nothing new for Point-Free. We are always on the lookout for ways to transform generic types into all new generic types because it unlocks all new capabilities from the type. We explore this concept in-depth in our collection discussing the many ways that map
, zip
and flatMap
appear naturally in the code we write everyday.
Next we will explore another SwiftUI API: ”redacted views.” SwiftUI makes it easy to redact the contents of a view, but unfortunately has less to say about redacting its logic.