Skip to content

Instantly share code, notes, and snippets.

@tfcporciuncula
Last active April 7, 2019 14:12
Show Gist options
  • Save tfcporciuncula/d24d515b86c6445eb77e71d447c52576 to your computer and use it in GitHub Desktop.
Save tfcporciuncula/d24d515b86c6445eb77e71d447c52576 to your computer and use it in GitHub Desktop.
BookInjection.kt
@Subcomponent
interface BookComponent {
@Subcomponent.Builder
interface Builder {
@BindsInstance fun bookView(bookView: BookView): Builder
fun build(): BookComponent
}
val presenter: BookPresenter
}
@Component(modules = ...)
interface ApplicationComponent {
...
// we can simply expose the subcomponent builder now
val bookComponentBuilder: BookComponent.Builder
}
// and here's how it looks like in the Activity
private val presenter =
MyApplication
.component
.bookComponentBuilder
.bookView(this)
.build()
.presenter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment