android5-7 Exercise 3: First-open refresh and the source of truth ============================================================== Where: in the ViewModel (or the repository), not the composable. A composable can be redrawn or recreated many times; a ViewModel runs once per screen lifetime. In the ViewModel: init { } // do not launch here (Chapter 3) Better: trigger from the data flow, for example in the repository's getNotesStream(), or have the route call viewModel.refreshIfEmpty() from a LaunchedEffect(Unit) once, with refreshIfEmpty checking whether the stream's first value is empty: fun refreshIfEmpty() { viewModelScope.launch { if (repository.getNotesStream().first().isEmpty()) refresh() } } (first() needs the kotlinx.coroutines.flow.first import.) The shape is general knowledge; avoid launching in init, as the Chapter 3 docs advice says. Why Room and not the Retrofit reply: one place holds the truth (docs: a local database is the recommended source of truth for offline-first). If the screen showed the reply directly, the list would vanish offline, and the screen would have two sources (the reply and the stored notes) to keep in step. Code unrun.