Skip to content

Instantly share code, notes, and snippets.

@manuelvicnt
Created August 5, 2022 12:20
Show Gist options
  • Save manuelvicnt/d78098f650cf480dc370535bc272893e to your computer and use it in GitHub Desktop.
Save manuelvicnt/d78098f650cf480dc370535bc272893e to your computer and use it in GitHub Desktop.
/* Copyright 2022 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
@Composable
fun AuthorRoute(...) {
val lifecycle = LocalLifecycleOwner.current.lifecycle
val uiState by produceState<AuthorScreenUiState>(
initialValue = viewModel.uiState.value
key1 = lifecycle
key2 = viewModel
) {
lifecycle.repeatOnLifecycle(state = STARTED) {
viewModel.uiState.collect { value = it }
}
}
AuthorScreen(...)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment