Skip to content

Instantly share code, notes, and snippets.

@Zhuinden
Created May 23, 2020 06:17
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/8143630b73d9c7f553580b57b7ae425c to your computer and use it in GitHub Desktop.
Save Zhuinden/8143630b73d9c7f553580b57b7ae425c to your computer and use it in GitHub Desktop.
AssistedInjection sample #2 - with 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 @AssistedInject constructor(
private val a: A,
private val b: B,
private val c: C,
@Assisted private val runtimeArg: RuntimeArg
) {
@AssistedInject.Factory
interface Factory {
fun create(runtimeArg: RuntimeArg): D
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment