Kotlin Flow and StateFlow interview questions
Cold and hot streams, StateFlow and SharedFlow, operators, one-off events and safe collection from the UI.
– interview-ready · 14 questions in this topic
– of 14 tried
Saved on this device. Interview-ready means you got it right on two different days. Guesses and hints count for less.
Questions
Practise this topic
Flashcards · 19
Flip, then say if you knew it. Needs JavaScript; every answer is also on its question page.
Quick quiz · 14 questions
One exercise per question, checked as you go. Needs JavaScript.
Mock interview · 2 sets
Timed, out loud, then tick what you covered. Needs JavaScript.
Fix this PR · 3 reviews
Review a diff like a senior: flag the lines you'd comment on. Needs JavaScript.
Quick facts
Recall the answer first, then tap Show to check.
MutableStateFlow.update
update { } applies a change with compare-and-set and retries, so concurrent updates are never lost.
shareIn replay
shareIn(scope, started, replay = 1) is like stateIn without the initial value and equality check.
SharingStarted.WhileSubscribed
WhileSubscribed(stopTimeoutMillis) keeps the upstream running that long after the last collector leaves.
debounce
debounce(300) emits a value only after 300 ms pass with no newer value.
first()
first() collects until the first value, returns it and cancels the upstream.
Printable cheat sheet · Review your weak spots in this topic
Share your progress
Sources: Question outline adapted from Android-Interview-Questions by Mohsen Mirhoseini, licensed under Apache 2.0. We reorganised the questions, rewrote every answer and added new ones. Credits and license