Hi, I’m migrating my android project to compose na...
# kodein
m
Hi, I’m migrating my android project to compose navigation. I’m using org.kodein.dikodein di framework compose7.22.0 for dependency injection. According to documentation https://kosi-libs.org/kodein/7.22/framework/compose.html I can use rememberViewModel() to retrieve a ViewModel in a @Composable, but it is marked as deprecated. I switched to org.kodein.dikodein di framework compose android7.22.0 but still have deprecation message... Also according to documentation I can use NavBackStackEntry.navGraphViewModel(navHostController), but this method seems not to exist... What am I doing wrong ?
1
r
Well this is not expected. Let me some time to investigate and come back to you
gratitude thank you 1
m
@romainbsl did you have time to investigate ?
r
Not yet, I planned to work on Kodein yesterday but didn't get the chance. will try later this week or at least on the week-end.
m
Ok, thanks for your feedback
r
Ok then, I don’t remember why rememberViewModel has been deprecated at that point, probably because I was thinking of migrating to Compose Multiplatform ViewModel. For the NavBackStackEntry extension, you can use the kodein module
kodein-di-framework-android-x-compose
. Here again I am trying to migrate to Compose Multiplatform, to remove Android specifics, but that’s not that simple. I am trying to move faster on the next release to fix those dependency and deprecation issue. Keep you posted.
m
Ok, thank you very much for the answer. We also plan to migrate our project to compose multiplatform, so we’ll keep on following kodein next steps with great interest
Hi @romainbsl would it be possible to just remove these (for the moment) useless deprecation messages ? Our code analyzer keep on sending warnings because of this, it’s quite annoying...
r
Will do a fix version for you this weekend. Sorry about that 😬 I’ve been overwhelmed a lot lately
v7.22.1 should work without deprecation warnings. Also, did you managed to work with
NavBackStackEntry.rememberNavGraphViewModel
?
m
Thank you very much 🙏🏻 Regarding rememberNavGraphViewModel I didn’t need to use it in the end ... so I did not try 🙄 Have a nice day ☀️
👍 1
I just upgraded to 7.22.1 but now, I can’t use rememberViewModel anymore... That’s not what I expected 🤔 Indeed I can’t see org.kodein package anymore
2
😬 1
r
Which module are you using?
m
kodein-di-conf = { module = “org.kodein.di:kodein-di-conf”, version.ref = “kodein” } kodein-di-framework-android-x = { module = “org.kodein.di:kodein-di-framework-android-x”, version.ref = “kodein” } kodein-di-compose-android = { module = “org.kodein.di:kodein-di-framework-compose-android”, version.ref = “kodein” }
r
Ok… i am dumb… I published the 7.23.0 instead 🤯
Try using 7.23.0
m
ok
using 7.23.0, I still have deprecation message on rememberViewModel
r
From
org.kodein.di.compose.android
or
org.kodein.di.compose
?
m
Copy code
org.kodein.di.compose.rememberViewModel
ah ok, I’ve just imported module org.kodein.di:kodein-di-framework-android-x-compose and use org.kodein.di.compose.android.rememberViewModel and now it’s fixed 🙂
r
Ok. This is not the one I’ve reactived….
Yes we’re not talking about the same package
But I published a 7.23.1 (still pending) to remove all depreciation on compose APIs I will rework everything for a cleaner release
m
Ok thank you, I ’ll let you know if everything is ok
r
7.23.1 should be available
🙌 1
m
I confirm with 7.23.1 there’s no rememberViewModel deprecation message anymore. Thanks !