Skip to content

Commit ffeec50

Browse files
Add playground files for conflate
1 parent a5e5052 commit ffeec50

File tree

1 file changed

+24
-0
lines changed
  • app/src/main/java/com/lukaslechner/coroutineusecasesonandroid/playground/flow/concurrency

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.lukaslechner.coroutineusecasesonandroid.playground.flow.concurrency
2+
3+
import kotlinx.coroutines.coroutineScope
4+
import kotlinx.coroutines.delay
5+
import kotlinx.coroutines.flow.conflate
6+
import kotlinx.coroutines.flow.flow
7+
8+
suspend fun main() = coroutineScope {
9+
10+
val flow = flow {
11+
repeat(5) {
12+
println("Emitter: Start Cooking Pancake $it")
13+
delay(100)
14+
println("Emitter: Pancake $it ready!")
15+
emit(it)
16+
}
17+
}.conflate()
18+
19+
flow.collect {
20+
println("Collector: Start eating pancake $it")
21+
delay(300)
22+
println("Collector: Finished eating pancake $it")
23+
}
24+
}

0 commit comments

Comments
 (0)