Kotlin Flow Basics
Emit and collect streams of data.
What Is a Flow?
A Flow is an asynchronous stream that emits multiple values over time. Think of it as a suspendable sequence you can transform and collect.
Building a Flow
The flow { } builder lets you emit values, optionally suspending between them.
fun numbers(): Flow<Int> = flow {
for (i in 1..3) {
delay(100)
emit(i)
}
}