When binding two singletons like this: ```single {...
# koin
s
When binding two singletons like this:
Copy code
single { SomeClass.Factory(...) }
single { SomeOtherClass.Factory(...) }
(on Kotlin Multi Platform), I get this error:
java.lang.IllegalStateException: InstanceRegistry already contains index 'Factory'
How can I make Koin use the qualified class name instead of just the inner class’ name? It is probably of this code in the jvm target of Koin:
Copy code
actual fun className(kClass: KClass<*>): String = kClass.java.simpleName
Why is
simpleName
used and not the full-name?
k
single<classname> {} doesn't work? Your factory should be returning the class, not to factory...
s
Same thing, doesn't work The
T
in
single<T>(...) { ... }
is reified, and if this
T
has the value
SomeType.SomeInnerType
, then Koin will index/cache this single binding with the string
”SomeInnerType"
, not the fully-qualified class name (
"package.SomeType.SomeInnerType"
) This means you can't create another Koin binding for
SomeInnerType
or
OtherClass.SomeInnerType
, etc. Koin will generate a runtime error that the
SomeInnerType
type is bound more than once.
🤦‍♂️ 1