Is it permitted to write extension methods/propert...
# dagger
j
Is it permitted to write extension methods/properties on a custom component? I.e im using this to reduce the verbosity of accessing an entrypoint.
Copy code
val AuthenticatedComponent.entryPoint: AuthenticatedComponentEntryPoint
    get(): AuthenticatedComponentEntryPoint {
        return EntryPoints.get(this, AuthenticatedComponentEntryPoint::class.java)
    }
And then I can inject with:
Copy code
private val myRepository = authManager.component!!.entryPoint.getMyRepository()
Edit: Just realized EntryPoints are specific to Hilt and this is a dagger channel
j
If it compiles and runs I think its permitted
Is this Android? You don't need any dependencies from application/activity scopes?
j
Yeah its Android,
AuthenticatedComponent
is a child of
SingletonComponent
j
You may consider
EntryPointAccessors.fromApplicaton(context, class)
see javadoc