Collect Flows from Swift
Bridge StateFlow to SwiftUI without leaks.
Flows Are Trickier
A Kotlin Flow emits many values over time. Swift has no built-in way to collect it, so you need a small bridge.
val users: StateFlow<List<User>>Why Not Just Await
Await fits a single result, but a Flow is a stream. You must keep listening, which means collecting inside a coroutine.
All lessons in this course
- How Kotlin Maps to Objective-C
- Suspend Functions as Swift async
- Collect Flows from Swift
- @ObjCName & Swift-Friendly APIs