Skip to content

Instantly share code, notes, and snippets.

@tfcporciuncula
Created December 14, 2018 20:09
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/806d02894d15da7fb1cd3d05abf1fd2e to your computer and use it in GitHub Desktop.
Save tfcporciuncula/806d02894d15da7fb1cd3d05abf1fd2e to your computer and use it in GitHub Desktop.
ApplicationComponent-with-module
@Singleton
@Component(modules = [ApplicationModule::class, YourModule::class, ThatOtherModule::class])
interface ApplicationComponent
@Module
class ApplicationModule(private val applicationContext: Context) {
@Provides fun provideApplicationContext(): Context = applicationContext
}
class YourApplication : Application() {
val component: ApplicationComponent by lazy {
DaggerApplicationComponent.builder()
.applicationModule(ApplicationModule(applicationContext))
.build()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment