Kotlin & Coroutines (50 Qs)•Part 1: Core Language, Type System & Syntax (1 - 10)
What is the difference between `LiveData`, `StateFlow`, and `SharedFlow`?
junior LevelkotlinCore Language
In Simple Words:
LiveData(Legacy Jetpack): Lifecycle-aware observable data holder. Conflates data to latest value, but tightly coupled to Android platform APIs and always runs on the Main thread.StateFlow(Modern Standard): Kotlin-native hot state holder Flow. Always holds a current value (stateFlow.value), conflates emissions, and provides state emissions across all application layers.SharedFlow: Hot event bus Flow without an initial value. Emits one-time events to multiple subscribers (e.g. navigation events, Snackbar toast messages).