apatrida
07/18/2016, 10:12 AMobject KodeinCognitoIdentity {
val module = Kodein.Module {
bind<CognitoJwtVerificationService>() with singleton { CognitoJwtVerificationService(instance(), instance()) }
bind<CognitoIdentityService>() with singleton { CognitoIdentityService(instance(), AmazonCognitoIdentityClient(instance<AWSCredentialsProviderChain>()), instance()) }
}
}
One of the classes it is registering:
class CognitoIdentityService(private val config: IdentityConfig, private val cognitoClient: AmazonCognitoIdentity, private val jwtVerification: CognitoJwtVerificationService) {
val LOG: Logger by KODEINNEEDED.withClass().instance() // how do I have a KODEIN instance here?!?
}
now, I want the logger and a few other things to NOT be in the constructor because for example they are based on the actual class (the logger for example should be a delegate withClass
)
With this model you would need to pass down the kodein instance to all modules (make each a function that returns a module) , yet Kodein instance is not known during module import. Without that you have to put everything in the constructor or use KodeinGlobalAware instead of specific instances.
Is there a way to inject the current kodein that is importing the module?