Out of curiosity, when I call ```single { Reposito...
# koin
j
Out of curiosity, when I call
Copy code
single { Repository(get(named("remote")),get(named("local")))
where is that Repository instance actually stored? and when I call
Copy code
val repo : Reposity by inject
where is that instance being pulled from again? is there any interesting magic happening here or is it literally keeping that instance in something like a hashmap?
s
Looking into the sources it seems like for non scoped modules, they are added here which happens in the loadModules which is what’s called from your normal
startKoin { modules(listOf(myModules…))}
then this is inside InstanceRegistry. Then to resolve it does this, so in short yeah it seems to be in a
safeHashMap
which is of type
MutableMap
which implementation is different depending on the actual platform Kotlin is being compiled for, a java.util.concurrent.ConcurrentHashMap for jvm so also Android as I understand.
j
ah yes, I forgot about concurrency, although I never thought that concurrency is actually an issue for setting up the DI types. Probably somewhere out there, somebody is doing something strange with the library that required this or since this is a library, it's better to be safe than getting a ConcurrentModificationException