InsertKoinIO / koin

Koin - a pragmatic lightweight dependency injection framework for Kotlin & Kotlin Multiplatform
https://insert-koin.io
Apache License 2.0
8.77k stars 695 forks source link

State is not restored correctly when using `koinNavGraphViewModel` #1828

Open JozefCeluch opened 3 months ago

JozefCeluch commented 3 months ago

Describe the bug

The state in a VM created using koinNavGraphViewModel doesn't seem to be restored correctly from the SavedStateHandle

To Reproduce Steps to reproduce the behavior: I added a more detailed description and a workaround that seems to be working fine using activityViewModel in the sample project linked below

Expected behavior keys inside SavedStateHandle should contain values when state is restored after process was killed by the system

Koin module and version: koin-androidx-navigation:3.6.0-alpha3 (I first noticed it in 3.5.3)

Snippet or Sample project to help reproduce https://github.com/JozefCeluch/koin-state-loss