Android Kotlin Flows

From bibbleWiki
Jump to navigation Jump to search

Introduction

This is a page to capture anything important about kotlin flows. This very similar to RxJava

Simple Example

 
fun fred() {
  val countDownFlow = flow<Int> {
    val startingValue = 10
    var currentValue = startingValue
    emit(currentValue)
    while (currentValue > 0) {
      delay(1000L)
      currentValue--
      emit(currentValue)
    }
  }
}