-
Notifications
You must be signed in to change notification settings - Fork 3
8. ViewModel extensions
Gabriel Brasileiro edited this page Jun 13, 2020
·
2 revisions
ViewModel extensions is an artifact to process your ViewModel creation.
You need only declare the scope of your ViewModel would you like instantiate.
This method permit you put all your init params and uncouple your ViewModel totally.
Example:
class MainActivity : AppCompatActivity(R.layout.activity_main) {
private val viewModel by getViewModel {
val screenMessage = getString(R.string.base_activity_default_screen_name)
MainViewModel(screenMessage, SingleLiveEvent(), MainReducer())
}
[...]
}