allan.conda
04/23/2021, 12:20 PMProfile(userId: String) {
val viewModel = hiltNavGraphViewModel<ProfileViewModel>()
DisposableEffect(userId) {
viewModel.loadProfile(userId) // don't trigger on config change
onDispose { }
}
val profile = viewModel.profile.collectAsState(...)
}
Actually, with compose-navigation it seems the backstack arguments are also in the ViewModel savedStateHandle. I’m wondering if it would be better to extract the userId from there instead.Zach Klippenstein (he/him) [MOD]
04/23/2021, 12:58 PMallan.conda
04/23/2021, 2:12 PMZach Klippenstein (he/him) [MOD]
04/23/2021, 2:15 PMallan.conda
04/23/2021, 2:16 PMallan.conda
04/23/2021, 2:18 PMallan.conda
04/23/2021, 2:20 PMZach Klippenstein (he/him) [MOD]
04/23/2021, 2:22 PMIan Lake
04/23/2021, 2:28 PMloadProfile
into the ViewModel if you only want to do it once and not on every config changeallan.conda
04/23/2021, 2:31 PMZach Klippenstein (he/him) [MOD]
04/23/2021, 2:32 PMZach Klippenstein (he/him) [MOD]
04/23/2021, 2:33 PMIan Lake
04/23/2021, 2:33 PMallan.conda
04/23/2021, 2:34 PMIan Lake
04/23/2021, 2:34 PMallan.conda
04/23/2021, 2:38 PM