Skip to content

Instantly share code, notes, and snippets.

@jmfayard
Created February 16, 2018 13:16
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 jmfayard/5313e2fa8afdbba84bb94ea5a0a52792 to your computer and use it in GitHub Desktop.
Save jmfayard/5313e2fa8afdbba84bb94ea5a0a52792 to your computer and use it in GitHub Desktop.
interface CatApi
interface CatService
interface CatRepository
interface Scheduler
interface Context
abstract class Application {
abstract fun onCreate()
}
abstract class AppCompatActivity
fun app(): AppComponent = TODO("")
fun common(): CommonComponent = TODO()
fun api(): ApiComponent = TODO()
interface AppComponent {
val moshi: Moshi
val context: Context
val retrofit: Retrofit
val okHttpClient: OkHttpClient
val catApi: CatApi
val catRepository: CatRepository
val catService: CatService
val mainThread: Scheduler
val backgroundThread: Scheduler
companion object {
lateinit var instance: AppComponent
}
}
interface ApiComponent: AppComponent {
companion object {
lateinit var instance: ApiComponent
}
}
interface CommonComponent : ApiComponent {
companion object {
lateinit var instance: CommonComponent
}
}
// Implement the union of all properties
abstract class ComponentsImplementation(
override val moshi: Moshi,
override val context: Context
) : CommonComponent, AppComponent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment