Skip to content

Instantly share code, notes, and snippets.

@dlemures
Last active July 2, 2019 21:57
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 dlemures/4b95d7fa0d62b0c548d91cc693cc3688 to your computer and use it in GitHub Desktop.
Save dlemures/4b95d7fa0d62b0c548d91cc693cc3688 to your computer and use it in GitHub Desktop.
KTP
// Root
class FooActivity {
val bar: Bar by Inject()
fun onCreate(state) {
KTP.openScope("Scope Name")
.installModule(MyModule())
.inject(this);
}
}
// Non-root
@InjectConstructor
class Bar(val d: Daniel, val s: Stephane) {
}
/*
1. `by Inject()` registers on a map<root, dependency>
2. openScope("Scope Name").inject(this) will go the map and set all the values.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment