<@U2JKKPMEE> We have been using Koin 2.0.1 in our...
# koin
r
@arnaud.giuliani We have been using Koin 2.0.1 in our Android SDK library. In our use case, the consuming application need to maintain two different instance of the SDK (based on different config passed). In koin 1.0, there was issue of scoping wherein the latest config passed would override the previous one. That was fixed in Koin 2.0.1 by implementing KoinComponent and overriding the
Copy code
getKoin() : Koin {
 return //custom koin instance maintained as a HashMap
}
but now once we have updated to 2.1.5 , we are again facing the issue. Is there a particular change in scoping in the latest release ?
a
2.1.5 introduced revamped Scope API
can you share a sample?
r
Copy code
// Koin set up
object WrapperClass {
private val koinInstanceMap = HashMap<String, Koin>()
Copy code
fun init() {
koinapplication = koinApplication {
  androidContext(context)
  modules(modules)
}

val instance =. CustomInstance()
koinapplication.koin.declare(instance)

koinInstanceMap[Id] = koinapplication.koin
}
}


Class CustomInstance : KoinComponent {

fun getKoin() : Koin {
  return koinInstanceMap[Id].koin
}

}
above is our setup. We maintain
koinInstanceMap
to hold both the koin instance
@arnaud.giuliani Do let me know if you need more information, any help will be much appreciated
a
what is the error behind that exactly?
any stacktrace?
r
There isnt a error or exception. But basically the
init
function above receives a Configuration object. The consuming application calls
init
twice with different configuration object as it needs two SDK instances. But the second configuration object overrides the first one whenever the dependency is provided
we faced the issue with Koin 1.0 but with Koin 2.0.1 it worked. Now with the latest update to 2.1.5 we are again facing that issue
Copy code
fun getKoin() : Koin {
  return koinInstanceMap[Id].koin
}
Since i am storing both the
KoinApplication
instance, the overriding issue should not have occurred. @arnaud.giuliani
a
can you extract a small github project?
it’s hard here to help you like that
r
Any initial thoughts of why it would cause the issue ?
a
not sure 😕
don’t know if there is a leak or something
at least I can try to have 2 isolated Koin instances ... but I think we already have such tests
r
so the configuration instance passed to init we give to koin as module { single { ConfigObject() } }
And later inject that in our use cases and view models
a
please put it somewhere on github, gists or something ... here in slack it’s just unreadable
r
yes will do
👍 1