This file contains hidden or 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
@Component(modules = [ApplicationModule::class, ...]) | |
interface ApplicationComponent { | |
fun plus(bookModule: BookModule): BookComponent | |
... | |
} |
This file contains hidden or 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
private val presenter = | |
MyApplication | |
.component | |
.plus(BookModule(this)) | |
.presenter |
This file contains hidden or 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
@Subcomponent(modules = [BookModule::class]) | |
interface BookComponent { | |
// let's assume BookPresenter has an @Inject-annotated constructor | |
val presenter: BookPresenter | |
} | |
@Module | |
class BookModule(@get:Provides val bookView: BookView) |
This file contains hidden or 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
@Subcomponent | |
interface BookComponent { | |
@Subcomponent.Builder | |
interface Builder { | |
@BindsInstance fun bookView(bookView: BookView): Builder | |
fun build(): BookComponent | |
} | |
val presenter: BookPresenter |
This file contains hidden or 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
@Subcomponent | |
interface BookComponent { | |
@Subcomponent.Factory | |
interface Factory { | |
fun create(@BindsInstance bookView: BookView): BookComponent | |
} | |
val presenter: BookPresenter | |
} |
This file contains hidden or 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
@Component(modules = [ApplicationModule::class, ...]) | |
interface ApplicationComponent { | |
... | |
} | |
@Module | |
class ApplicationModule(private val applicationContext: Context) { | |
@Provides fun provideApplicationContext() = applicationContext | |
} |
This file contains hidden or 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
@Module | |
class ApplicationModule(@get:Provides val applicationContext: Context) |
This file contains hidden or 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
DaggerApplicationComponent | |
.builder() | |
.applicationContext(applicationContext) | |
.build() |
This file contains hidden or 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
@Module | |
object BookPresenterModule { | |
@Provides @JvmStatic | |
fun provideBookPresenter(bookPresenter: BookPresenterImpl): BookPresenter = bookPresenter | |
} |
This file contains hidden or 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
@Module | |
abstract class BookPresenterModule { | |
@Binds abstract fun bindBookPresenter(bookPresenter: BookPresenterImpl): BookPresenter | |
} |