Data Flow Through SwiftUI
This article may be considered a condensed version of the (highly-recommended) WWDC19 talk, “Data Flow Through SwiftUI”, along with a few thoughts and insights of my own. It represents my own, current understanding of data flow in SwiftUI, derived from experimentation over the past two months.
Let’s start with an important quote from the aforementioned talk:
Data is a first class citizen in SwiftUI.
This is the crux of what makes SwiftUI not only so beautifully elegant, but also extremely ergonomic.
The Two Key Principles
SwiftUI is designed to be declarative and functional. As such, data flow in SwiftUI revolves around two key principles:
- Reading data creates dependencies.
- Every piece of data has a source of truth.
This all seems quite abstract, and so we shall revisit a popular definition for declarative programming:
“You know, imperative programming is like* how you do...
Continue reading →