Created
July 27, 2019 19:04
-
-
Save Audhil/f786e66a355a1bd87f8a07724ea51884 to your computer and use it in GitHub Desktop.
The World smallest Dagger2 sample usage - https://medium.com/@elye.project/dagger-2-for-dummies-in-kotlin-with-one-page-simple-code-project-618a5f9f2fe8
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 MainActivity : AppCompatActivity() { | |
@Inject lateinit var info: Info | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
DaggerMagicBox.create().poke(this) | |
text_view.text = info.text | |
} | |
} | |
class Info @Inject constructor() { | |
val text = "Hello Dagger 2" | |
} | |
@Component | |
interface MagicBox { | |
fun poke(app: MainActivity) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment