@arnaud.giuliani I tried it, and each time a new instance is created. Below is the code showing how I do it and the
RegistrationViewModel
is not shared between screens. What am I missing to achieve the result that this
ViewModel
will be the same between screens? 😄
Here is entry screen:
composable(EMAIL_ROUTE) {
val vm: RegistrationViewModel = koinViewModel<RegistrationViewModel>()
val state = vm.registrationState.collectAsState()
EmailScreen(
registrationState = state.value,
onNavigateBack = onNavigateBack,
onNextClicked = onNextClicked,
onEmailValueChange = vm::onEmailEnter,
)
}
And Here is my next screen that I'm navigating from
EmailScreen
composable(PASSWORD_ROUTE) {
val vm: RegistrationViewModel = koinViewModel<RegistrationViewModel>()
val state = vm.registrationState.collectAsState()
PasswordScreen(
registrationState = state.value,
onNavigateBack = onNavigateBack,
onPasswordChange = vm::onPasswordEnter,
onCreateAccount = onCreateAccount,
)
}