Nick
01/27/2025, 10:53 AMViewModel
class SomeViewModel : ViewModel() {
private val state = MutableStateFlow(WelcomeState.Initial)
@Composable
fun collectState() = state.collectAsStateWithLifecycle().value
}
If this collectState
function is called from another composable, what lifecycle
will the collectAsStateWithLifecycle
be referring to? The ViewModel lifecycle or the lifecycle from the calling composable?Stylianos Gakis
01/27/2025, 12:04 PMZach Klippenstein (he/him) [MOD]
01/27/2025, 4:19 PMNick
01/28/2025, 9:13 AM