EP
Size: a a a
EP
EP
EP
AM
AN
AM

AN
AM
EP
AN
EP
AN
EP
EP
EP
AN
AM
EP
fun testFlow(name: String, timeout: Long): Flow<Int> = flow {
for (i in 1..3) {
delay(timeout)
println("Emitting $i from ${name}")
emit(i)
}
}
Flow.amb(
testFlow("First", 60),
testFlow("Second", 50),
testFlow("Third", 70))
.collect { println("Received ${it}") }Emitting 1 from Second
Received 1
Emitting 2 from Second
Received 2
Emitting 3 from Second
Received 3
AN
fun testFlow(name: String, timeout: Long): Flow<Int> = flow {
for (i in 1..3) {
delay(timeout)
println("Emitting $i from ${name}")
emit(i)
}
}
Flow.amb(
testFlow("First", 60),
testFlow("Second", 50),
testFlow("Third", 70))
.collect { println("Received ${it}") }Emitting 1 from Second
Received 1
Emitting 2 from Second
Received 2
Emitting 3 from Second
Received 3
EP
