Last active
September 13, 2019 18:56
-
-
Save alejandro-rios/d464f536110532342fd65b60dc360bb0 to your computer and use it in GitHub Desktop.
Basic Hello World with Kodein
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 Info(val text: String) | |
// Module | |
val bag = Kodein.Module("module name") { | |
bind<Info>() with provider { Info("Hello Kodein") } | |
} | |
// MainActivity | |
class MainActivity : AppCompatActivity(), KodeinAware { | |
// Bind with our activity | |
override val kodein = Kodein { | |
import(bag) | |
} | |
// Retrieve Dependencies | |
private val magicBox: Info by instance() | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
text_view.text = magicBox.text | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment