What is the difference between StateFlow and LiveData?
- A StateFlow is not lifecycle-aware by itself and must be collected within repeatOnLifecycle
- B LiveData is not lifecycle-aware
- C StateFlow cannot hold a current value
- D They are identical
Answer
StateFlow is not lifecycle-aware by itself and must be collected within repeatOnLifecycle
Without repeatOnLifecycle or collectAsStateWithLifecycle, collection continues while the app is backgrounded, wasting work.





