Order the steps
Order one trip around the unidirectional loop after a pull-to-refresh.
- The UI calls
viewModel.onRefresh() - The repository fetches and saves to the database
- The UI recomposes from the new state
- The ViewModel sets
isRefreshing = truein UiState - The database flow emits; the ViewModel builds a new UiState
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A D B E C
- The UI calls
viewModel.onRefresh()Events go up as function calls. - The ViewModel sets
isRefreshing = truein UiState Only the state holder changes state. - The repository fetches and saves to the database The data layer does the work.
- The database flow emits; the ViewModel builds a new UiState New data arrives as state.
- The UI recomposes from the new state The UI only renders.