Android Kotlin Flows: Difference between revisions
Jump to navigation
Jump to search
Created page with "=Introduction= This is a page to capture anything important about kotlin flows. This very similar to RxJava =Simple Example= <syntaxhighlight lang="kotlin"> fun fred() { val countDownFlow = flow<Int> { val startingValue = 10 var currentValue = startingValue emit(currentValue) while (currentValue > 0) { delay(1000L) currentValue-- emit(currentValue) }..." |
|||
Line 3: | Line 3: | ||
=Simple Example= | =Simple Example= | ||
<syntaxhighlight lang="kotlin"> | <syntaxhighlight lang="kotlin"> | ||
fun fred() { | |||
val countDownFlow = flow<Int> { | |||
val startingValue = 10 | |||
var currentValue = startingValue | |||
emit(currentValue) | |||
while (currentValue > 0) { | |||
delay(1000L) | |||
currentValue-- | |||
emit(currentValue) | |||
} | } | ||
} | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 01:53, 18 March 2025
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)
}
}
}