Halil Ozercan
09/02/2020, 8:13 PM// using itemId as key would still give me the same viewModel when this composable gets recreated
val key = remember(itemId) { UUID.randomUUID().toString() }
val commentsViewModel = viewModel<CommentsViewModel>(key = key)
However, I cannot remove this particular viewModel from the store without removing other viewModels that were stored in the same place. How should I proceed with this? Is this an anti-pattern?Ian Lake
09/02/2020, 9:42 PMTimo Drick
09/02/2020, 10:50 PMonActive { log("onActive") ; onDispose { log("dispose") } }
Sean McQuillan [G]
09/02/2020, 10:52 PMCompositionLifecycleObserver
that's responsible for the cleanup code.
https://cs.android.com/androidx/platform/frameworks/support/+/androidx-master-dev:compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/CompositionLifecycleObserver.kt;l=37?q=CompositionLifecycleTimo Drick
09/02/2020, 10:52 PMSean McQuillan [G]
09/02/2020, 10:52 PMonEnter
and onLeave
when it's remembered (or forgotten) by compositionTimo Drick
09/02/2020, 10:54 PMIan Lake
09/02/2020, 11:16 PMviewModel
if you want to have state that is retained over configuration changes (remember
and the like do not do that)Timo Drick
09/03/2020, 12:00 AMrememberSavedInstanceState
Ian Lake
09/03/2020, 12:39 AMviewModel
and rememberSavedInstanceState
would work with the upcoming Navigation framework integrationHalil Ozercan
09/03/2020, 6:39 AM