gotoOla
08/31/2020, 9:30 AMefemoney
08/31/2020, 9:37 AMApplication and ApplicationCall components both have Attributes which is a type safe map where you can put arbitrary data (depending on the scope)gotoOla
08/31/2020, 9:44 AMgotoOla
08/31/2020, 9:45 AMefemoney
08/31/2020, 9:48 AMService lives would probably be where the AuthSingleton is injected which would probably be in the Application scope via its Attributesefemoney
08/31/2020, 9:58 AMinternal val Application.component
get() = attributes.computeIfAbsent(ApplicationComponentKey) {
DaggerApplicationComponent.factory().create(this, environment)
}
internal val ApplicationCall.component
get() = attributes.computeIfAbsent(CallComponentKey) {
application.component.newCallComponentFactory().create(this)
}
private val ApplicationComponentKey = AttributeKey<ApplicationComponent>("ApplicationComponentKey")
private val CallComponentKey = AttributeKey<CallComponent>("CallComponentKey")
The DI graph (represented by the generated Dagger component) is contained in the Application s Attributes. This way, objects from the ApplicationEnvironment or the Application itself can be inputs into the graph which lives as long as the Application is running.gotoOla
08/31/2020, 11:02 AMefemoney
08/31/2020, 11:02 AM@Scope s to be explicit (@ApplicationScope & @CallScope)efemoney
08/31/2020, 11:05 AMgotoOla
08/31/2020, 11:06 AMgotoOla
08/31/2020, 11:07 AMgotoOla
08/31/2020, 11:07 AMgotoOla
08/31/2020, 11:08 AMefemoney
08/31/2020, 11:16 AMCool. I’m not running any DI framework now but we deal with that on our ownNice! I don’t know of any identifier but should be easy enough to generate one (and cache/store it) on the client and send to your ktor BE