Flows

kotlinx.coroutines 1.2.1

  • High level API on top of coroutines and channels
  • Similar to Rx Streams

fun foo() : Flow<Int> = flow { 
  for (i in 1..3) { 
    delay(100)
    emit(i)
  }
}



fun main() = runBlocking<Unit> { 
  foo().collect { value ->  println(value) }
}


Back Home Next