Android Kotlin Flows

From bibbleWiki
Revision as of 01:52, 18 March 2025 by Iwiseman (talk | contribs) (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) }...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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)
            }
        }
    }