fmd
06/30/2016, 9:48 AMval kodein = Kodein { bind<TimeProvider>() with singleton { TimeProviderImpl() } }
With injecting I again refer to the dependency via its interface type
val timeProvider by appKodein.lazyInstance<TimeProvider>()
However, since both TimeProvider
and TimeProviderImpl
are required to be publicly visible, the IDE will hint both classes as type argument at the injection line. This may lead to coding mistakes (just happened to me) that will lead to runtime errors. Is there some recommended way to structure dependencies (interfaces and their implementations)?
The main reason for using injection here is making it testable by later on injecting deterministic testing mocks. Right now the production dependency interface and implementation reside in the same file, whereas the Kodein instance is inside my Android Application
instance.