Skip to content

Instantly share code, notes, and snippets.

@Zhuinden
Created May 23, 2020 06: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 Zhuinden/3ea36a728d2933e63808b6296a658e62 to your computer and use it in GitHub Desktop.
Save Zhuinden/3ea36a728d2933e63808b6296a658e62 to your computer and use it in GitHub Desktop.
AssistedInjection sample #1 - without assisted injection
class RuntimeArg {}
@Singleton class A @Inject constructor()
@Singleton class B @Inject constructor(private val a: A)
@Singleton class C @Inject constructor(private val b: B)
class D(
private val a: A,
private val b: B,
private val c: C,
private val runtimeArg: RuntimeArg
) {
class Factory @Inject constructor(
private val a: A,
private val b: B,
private val c: C
) {
fun create(runtimeArg: RuntimeArg) = D(a, b, c, runtimeArg)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment