Level 1 · Apprentice0 XP
One real function, followed from Kotlin down to the CPU.
Step 1 / 7
ProblemLiveData is Android's observable value holder: the screen watches it, and setValue or postValue change it. A background loop calls liveData.postValue(i) quickly. The observer receives only the last value. Is that a bug?
← → step
Before this: Event loops: the main thread is a loop
🛠️ Your turn
Reading is not the skill, doing is. Try for ten minutes before you open the hint. Getting stuck first is what makes the solution stick.
1.Implement MiniLiveData twice: once with synchronized, once with AtomicReference.getAndSet. Post 1 to 1,000 from a background thread and count how many values the observer receives. Then rewrite it with MutableStateFlow.