0PricingLogin
Kotlin Multiplatform Academy · Lesson

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

  1. How Kotlin Maps to Objective-C
  2. Suspend Functions as Swift async
  3. Collect Flows from Swift
  4. @ObjCName & Swift-Friendly APIs
← Back to Kotlin Multiplatform Academy