xref: /aosp_15_r20/external/kotlinx.coroutines/kotlinx-coroutines-core/jvm/test/guide/example-flow-36.kt (revision 7a7160fed73afa6648ef8aa100d4a336fe921d9a)

<lambda>null1 // This file was automatically generated from flow.md by Knit tool. Do not edit.
2 package kotlinx.coroutines.guide.exampleFlow36
3 
4 import kotlinx.coroutines.*
5 import kotlinx.coroutines.flow.*
6 
7 // Imitate a flow of events
8 fun events(): Flow<Int> = (1..3).asFlow().onEach { delay(100) }
9 
<lambda>null10 fun main() = runBlocking<Unit> {
11     events()
12         .onEach { event -> println("Event: $event") }
13         .launchIn(this) // <--- Launching the flow in a separate coroutine
14     println("Done")
15 }
16