Skip to content

Instantly share code, notes, and snippets.

@manuelvicnt
Last active March 7, 2023 14:17
Show Gist options
  • Save manuelvicnt/03fa933f5ef386a14279148f1f083a97 to your computer and use it in GitHub Desktop.
Save manuelvicnt/03fa933f5ef386a14279148f1f083a97 to your computer and use it in GitHub Desktop.
/* Copyright 2022 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
@Composable
fun AuthorRoute(
onBackClick: () -> Unit,
modifier: Modifier = Modifier,
viewModel: AuthorViewModel = hiltViewModel()
) {
- val uiState: AuthorScreenUiState by viewModel.uiState.collectAsState()
+ val uiState: AuthorScreenUiState by viewModel.uiState.collectAsStateWithLifecycle()
AuthorScreen(
authorState = uiState.authorState,
newsState = uiState.newsState,
modifier = modifier,
onBackClick = onBackClick,
onFollowClick = viewModel::followAuthorToggle,
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment