If my app has never refreshed some user details before upon launch, I want it to do so.
I tried putting the call to refresh in a LaunchedEffect(Unit)
. Now let's say the request fails. I can have a snackbar with a retry button, but what about when the user presses the back button and the app is reopened? No recomp seems to occur to automatically try again, so is the only option in this case to tie the logic to the lifecycle of the app, something like this answer? It seems very counterintuitive to Compose, and a very common use case to refresh data when an app is resumed from the background.
when (uiState) {
HomeUiState.RequiresInitializing -> {
LaunchedEffect(Unit) {
refresh()
}
Box(
modifier = modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
LoadingWheel()
}
}
}