I’m opening this to discuss about the problem Koin...
# koin-contributors
n
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
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
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
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
Ok, let me create another repo with traditional view system. It'll be ready this week.
a
oh, yeah 🙂 great 👍
n
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
I can perhaps work on “official” sample also 🤔
n
I am able to help you with anything, so feel free to ask for it.
a
If you have something around, it can help yes. I don’t know if there is a graph nav sample app 🤔
from google
n
I don’t know if there’s one from Google but it should be super quick to do. Let me handle that.
a
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
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
Great, let me check that this week 👍
finally another fix to help set a
ViewModelStoreOwner
and then the navigation one if needed
message has been deleted
n
Looks good! 👍
a
great