Skip to content

Instantly share code, notes, and snippets.

@tfcporciuncula
Created March 8, 2023 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tfcporciuncula/9824df99a4fff23f19f7c098cacd7c20 to your computer and use it in GitHub Desktop.
Save tfcporciuncula/9824df99a4fff23f19f7c098cacd7c20 to your computer and use it in GitHub Desktop.
class GreeterApplication : Application(), ApplicationComponentProvider {
override val component by lazy(LazyThreadSafetyMode.NONE) {
DaggerApplicationComponent.factory().build(applicationContext)
}
}
interface ApplicationComponentProvider {
val component: ApplicationComponent
}
// To help accessing the component later
val Context.applicationComponent get() = (applicationContext as ApplicationComponentProvider).component
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment