From 298a9dd960cd19a635b50c0d731dd3c9bddece97 Mon Sep 17 00:00:00 2001 From: Romain Boisselle Date: Mon, 3 Apr 2023 22:34:39 +0200 Subject: [PATCH] Create 2 new modules to manage Jetpack Compose specific behaviours --- .../di/compose/android/navigation/navGraphViewModel.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/framework/compose/kodein-di-framework-compose-android-navigation/src/androidMain/kotlin/org/kodein/di/compose/android/navigation/navGraphViewModel.kt b/framework/compose/kodein-di-framework-compose-android-navigation/src/androidMain/kotlin/org/kodein/di/compose/android/navigation/navGraphViewModel.kt index d820538c..6589336e 100644 --- a/framework/compose/kodein-di-framework-compose-android-navigation/src/androidMain/kotlin/org/kodein/di/compose/android/navigation/navGraphViewModel.kt +++ b/framework/compose/kodein-di-framework-compose-android-navigation/src/androidMain/kotlin/org/kodein/di/compose/android/navigation/navGraphViewModel.kt @@ -30,7 +30,7 @@ public inline fun NavBackStackEntry.rememberNavGraphVie ): ViewModelLazy = with( localDI() ) { - remember { + remember(this@rememberNavGraphViewModel) { ViewModelLazy( viewModelClass = VM::class, storeProducer = { navHostController.getBackStackEntry(getParentId()).viewModelStore }, @@ -55,7 +55,7 @@ public inline fun NavBackStackEntry.navGraphViewModel( navHostController: NavHostController, tag: String? = null ): VM = with(localDI()) { - remember { + remember(this@navGraphViewModel) { val provider = ViewModelProvider( navHostController.getBackStackEntry(getParentId()).viewModelStore, KodeinViewModelScopedSingleton(di = di, tag = tag) @@ -90,7 +90,7 @@ public inline fun NavBackStackEntry.rem ): ViewModelLazy = with( localDI() ) { - remember { + remember(this@rememberNavGraphViewModel) { ViewModelLazy( viewModelClass = VM::class, storeProducer = { navHostController.getBackStackEntry(getParentId()).viewModelStore }, @@ -126,7 +126,7 @@ public inline fun NavBackStackEntry.nav tag: String? = null, arg: A, ): VM = with(localDI()) { - remember { + remember(this@navGraphViewModel) { val provider = ViewModelProvider( navHostController.getBackStackEntry(getParentId()).viewModelStore, KodeinViewModelScopedFactory(