Last active
October 7, 2015 15:10
-
-
Save desseim/8244457d5a3b1dcdb954 to your computer and use it in GitHub Desktop.
Injection in >= M14 Kotlin code with Dagger2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExampleInjectedActivity : Activity() { | |
@Inject lateinit var controller: ExampleController | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.example_layout) | |
//controller.doThing() // would compile but throw at runtime | |
component().inject(this) | |
controller.doThing() // works, no need for null-safe syntax | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment