uli
02/19/2019, 5:39 PMConsoleLogger
, AndroidLogger
and WebLogger
.
I inject it like this:
object InjectedLogger : KodeinGlobalAware {
val logger: CommonLogger by instance()
}
On JVM and Android I can bind the logger with it's implementation type (ConsoleLogger
):
bind<ConsoleLogger>() with singleton { ConsoleLogger() }
On JS and native I have to bind to the interface type (CommonLogger
):
bind<CommonLogger>() with singleton { ConsoleLogger() }
Otherwise, injecting fails with:
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?