Created
December 14, 2018 20:09
-
-
Save tfcporciuncula/806d02894d15da7fb1cd3d05abf1fd2e to your computer and use it in GitHub Desktop.
ApplicationComponent-with-module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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