This is a small, focused learning example that shows how SwiftUI reacts to changing state using the modern Observation framework. A reference type is annotated with the @Observable macro, and the view automatically re-renders whenever one of its tracked properties changes. It is intentionally minimal so the data-flow mechanics are easy to follow.
The app displays a simple user profile card and increments a follower count on a button tap, demonstrating how a mutation on an observable object drives a live UI update — no @Published, ObservableObject, or manual objectWillChange plumbing required.
- Marking a reference type with the
@Observablemacro from theObservationframework. - Letting SwiftUI automatically track and re-render only the views that read a changed property.
- Mutating observable state (
followerCount += 1) directly from aButtonaction. - Building a basic profile layout with
VStack,Text, and typography/foreground styling. - Using
.buttonStyle(.borderedProminent)and#Previewfor the SwiftUI canvas.
git clone https://github.com/ahmetbostanciklioglu/DataFlowApp-SwiftUI.git
cd DataFlowApp-SwiftUI
open DataFlowApp-SwiftUI.xcodeprojThen select an iOS Simulator and press Command-R to build and run.
- iOS 18.1+
- Xcode 16 or later
- Swift 5.0
Ahmet Bostancıklıoğlu — @ahmetbostanciklioglu · ahmetbostancikli@gmail.com
⭐ If this helped you, consider giving the repo a star!