We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug Value not being registered in ViewModel when injecting SavedStateHandle
Koin module and version: 4.1.0-Beta5
To Reproduce TypeSafe Navigation:
composable<Route.AddEditDreamScreen> { backStackEntry -> val args = backStackEntry.toRoute<Route.AddEditDreamScreen>() val image = args.backgroundID val addEditDreamViewModel = koinViewModel<AddEditDreamViewModel>() println("Dream ID: ${navController.currentBackStackEntry?.savedStateHandle?.get<String>("dreamID")}") AddEditDreamScreen( dreamImage = image, onMainEvent = { onMainEvent(it) }, onAddEditDreamEvent = { addEditDreamViewModel.onEvent(it) }, animateVisibilityScope = this, onNavigateToDreamJournalScreen = { navController.popBackStack() navController.navigate(Route.DreamJournalScreen) }, onImageClick = { imageID -> navController.navigate( Route.FullScreenImageScreen(imageID) ) } ) }
Koin:
val viewModelModule = module { viewModelOf(::AddEditDreamViewModel) }
ViewModel:
class AddEditDreamViewModel( private val savedStateHandle: SavedStateHandle, private val dreamUseCases: DreamUseCases, private val authRepository: AuthRepository, private val dictionaryRepository: DictionaryRepository, private val vibratorUtil: VibratorUtil, ) : ViewModel() { private val _addEditDreamState = MutableStateFlow( AddEditDreamState( authRepository = authRepository ) ) val addEditDreamState: StateFlow<AddEditDreamState> = _addEditDreamState.asStateFlow() init { savedStateHandle.get<String>("dreamID")?.let { dreamId -> //value is Null (worked before transition to KMM) } }
This problem started after I transitioned my project from Android to KMM. Am I doing something wrong?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
Value not being registered in ViewModel when injecting SavedStateHandle
Koin module and version:
4.1.0-Beta5
To Reproduce
TypeSafe Navigation:
Koin:
ViewModel:
This problem started after I transitioned my project from Android to KMM. Am I doing something wrong?
The text was updated successfully, but these errors were encountered: