Last active
August 30, 2019 14:58
-
-
Save vbevans94/8153bdc5c1738ae32f673d2acb0baacb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyCollector : FlowCollector<Int> { | |
override suspend fun emit(value: Int) { | |
print(value) | |
} | |
} | |
class MyFlow : Flow<Int> { | |
@InternalCoroutinesApi | |
override suspend fun collect(collector: FlowCollector<Int>) { | |
for (i in 1..10) { | |
delay(100) | |
collector.emit(i) | |
} | |
} | |
} | |
@InternalCoroutinesApi | |
fun main() = runBlocking { | |
MyFlow().collect(MyCollector()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment