Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vbevans94/8153bdc5c1738ae32f673d2acb0baacb to your computer and use it in GitHub Desktop.
Save vbevans94/8153bdc5c1738ae32f673d2acb0baacb to your computer and use it in GitHub Desktop.
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