Skip to content

Instantly share code, notes, and snippets.

@Skyyo
Last active August 30, 2022 08:31
Show Gist options
  • Save Skyyo/b25d18a8ce474f48a8d4f68c8df77718 to your computer and use it in GitHub Desktop.
Save Skyyo/b25d18a8ce474f48a8d4f68c8df77718 to your computer and use it in GitHub Desktop.
@Composable
fun LifecycleAwareCurrenciesScreen(viewModel: LifecycleAwareCurrenciesViewModel) {
val currencyPrices by viewModel.currencyPrices.collectAsStateWithLifecycle()
LazyColumn {
itemsIndexed(currencyPrices, { _, item -> item.id }) { index, currencyPrice ->
LifecycleAwareCurrencyPriceCard(
currencyPrice = currencyPrice,
currencyPriceUpdateFlow = viewModel.provideCurrencyUpdateFlow(),
onDisposed = { viewModel.onDisposed(index) },
onCurrencyUpdated = { newPrice -> viewModel.onCurrencyUpdated(newPrice, index) })
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment