https://kotlinlang.org logo
#kodein
Title
# kodein
u

uli

02/19/2019, 5:39 PM
Hi all, i experience some platform speific behavior when using kodein on JVM/JS and native. I have an interface `CommonLogger`with three implementations
ConsoleLogger
,
AndroidLogger
and
WebLogger
. I inject it like this:
Copy code
object InjectedLogger : KodeinGlobalAware {
    val logger: CommonLogger by instance()
}
On JVM and Android I can bind the logger with it's implementation type (
ConsoleLogger
):
Copy code
bind<ConsoleLogger>() with singleton { ConsoleLogger() }
On JS and native I have to bind to the interface type (
CommonLogger
):
Copy code
bind<CommonLogger>() with singleton { ConsoleLogger() }
Otherwise, injecting fails with:
Copy code
Uncaught exception from Kotlin's main: org.kodein.di.Kodein.NotFoundException: No binding found for bind<CommonLogger>() with ?<InjectedLogger>().? { ? }
Registered in this Kodein container:
        bind<ConsoleLogger>() with singleton { ConsoleLogger }
Which behaviour is expected? Is either one a bug?