https://kotlinlang.org logo
Title
n

Nacho Ruiz Martin

08/09/2021, 1:54 PM
I’m opening this to discuss about the problem Koin is facing with the usage of ViewModel + Compose + Navigation component on Android. See https://kotlinlang.slack.com/archives/C67HDJZ2N/p1628005816001100 for further info.
a

arnaud.giuliani

08/09/2021, 4:00 PM
great, let me review it and see how we can organise
ok, first to understand it will be how we can hook over ViewModel factory instances to keep a scoped instance for a nav graph
A regular ViewModel has its own factory, managed by the underlying Android system
it will create the right instances by its own
Perhaps worse take a look at Hilt way of doing it 🤔
else play around the ViewModelFactory arguments
n

Nacho Ruiz Martin

08/12/2021, 4:29 PM
Is this something to be addressed separately from Compose? I mean, the traditional way of injecting ViewModels should be able to scope it to a nav graph too, right? Is this already possible? Also, is Hilt open source?
a

arnaud.giuliani

08/26/2021, 9:11 AM
Need to check if Koin ViewModelFactory can get/create from a given scope. In the postivie case, we could just adapt/offer a way to work on navigation graph
else at least, we need to be sure that ViewModel can be scoped/create in a scope 🤔
I will take a bit of time to check your code, I believe NavGraph scope with Koin can be quite easy
👍 1
🙇 1
arf, your sample is in compose 😛
would be great to go with “dry” API before making the Compose version
n

Nacho Ruiz Martin

09/27/2021, 6:26 PM
Ok, let me create another repo with traditional view system. It'll be ready this week.
a

arnaud.giuliani

09/28/2021, 8:10 AM
oh, yeah 🙂 great 👍
n

Nacho Ruiz Martin

10/05/2021, 11:13 AM
Hey man, I was busy last week so I couldn’t create the sample repo. Do you still need it? I’ve seen that you’re already working on the ViewModel API rework.
a

arnaud.giuliani

10/05/2021, 12:10 PM
I can perhaps work on “official” sample also 🤔
n

Nacho Ruiz Martin

10/05/2021, 12:48 PM
I am able to help you with anything, so feel free to ask for it.
a

arnaud.giuliani

10/05/2021, 2:22 PM
If you have something around, it can help yes. I don’t know if there is a graph nav sample app 🤔
from google
n

Nacho Ruiz Martin

10/07/2021, 9:34 AM
I don’t know if there’s one from Google but it should be super quick to do. Let me handle that.
a

arnaud.giuliani

10/07/2021, 1:30 PM
ok, just something super quick. one activity 2 fragments, to make just a transition and be sure we can handle a ViewModel from the nav graph
thanks 🙏
n

Nacho Ruiz Martin

10/07/2021, 1:30 PM
Great! 💪
https://github.com/iruizmar/koin-nav-compose-view-toy There you have. Very basic stuff, let me know if you need something different.
a

arnaud.giuliani

10/12/2021, 10:17 AM
Great, let me check that this week 👍
finally another fix to help set a
ViewModelStoreOwner
and then the navigation one if needed
n

Nacho Ruiz Martin

12/08/2021, 6:18 PM
Looks good! 👍
a

arnaud.giuliani

12/09/2021, 9:01 AM
great