URGENT!!! (KoinViewModel doesn't scope properly for Lifecycle Changes on Android (For Kotlin Multiplatform) #1944
Labels
status:checking
currently in analysis - discussion or need more detailed specs
status:wait_feedback
viewmodel
Milestone
Describe the bug
Currently I'm trying to load a view model into a fragment, which is using android navigation.
The issue here is that if I try to load a view model annotated with KoinViewModel, if the fragment/activity gets destroyed, and the lifecycle changes, the ViewModel recreates a new instance of itself, and it causes the whole process to break.
If I change orientation, or if the fragment gets destroyed, a new instance of MyViewModel gets recreated, and it causes an issue because the app has subscriptions/workers running on initialisation.
Expected behavior
What I expect is that the view model itself survives configuration changes, across the lifecycle. However it's not been scoped properly, and I'm forced to use Singleton Annotations for ViewModels, and manually do cleanup/deinit for any resources
Koin module and version:
implementation("io.insert-koin:koin-android:3.5.6")
implementation("io.insert-koin:koin-core:3.5.6")
Snippet or Sample project to help reproduce
This is a commercial project, so I can't upload the source code here.
The text was updated successfully, but these errors were encountered: