0Pricing
Android Academy · Lesson

StateFlow and SharedFlow

Expose reactive state from your app.

Hot Flows

Unlike cold flows, StateFlow and SharedFlow are hot: they exist independently of collectors and can be shared among many.

StateFlow Is a State Holder

A StateFlow always holds one current value. New collectors immediately receive that latest value. It is perfect for UI state.

private val _count = MutableStateFlow(0)
val count: StateFlow<Int> = _count.asStateFlow()

All lessons in this course

  1. Coroutine Basics and Scopes
  2. viewModelScope and Dispatchers
  3. Kotlin Flow Basics
  4. StateFlow and SharedFlow
← Back to Android Academy