kodeinject
A small library allowing constructor dependency injection for applications using Kodein.
Usage
class Application(db: Database) {
// stuff goes here
}
val kodein = Kodein {
bind<Database>() with singleton { MongoDB("127.0.0.1", 27017) }
bind() from injected<Application>()
}kodeinject will automatically instantiate your injected() classes using
bindings from the Kodein container.
Singleton
val kodein = Kodein {
bind() from injectedSingleton<Application>()
}Use injectedSingleton() to cache the dependency instead of creating a new
instance for each access.