Last active
July 22, 2019 14:07
-
-
Save jraska/071e28ced67c7ca7da77e4c50b98af7e to your computer and use it in GitHub Desktop.
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 ContactsViewModel(val getContactsUseCase: GetContactsUseCase, parameters: Parameters) : ViewModel() { | |
private val contactsLiveData: LiveData<Contacts> by lazy { | |
val liveData = MutableLiveData<Contacts>() | |
getContactsUseCase.loadContacts(parameters) { liveData.value = it } | |
return@lazy liveData | |
} | |
fun contacts(parameters: Parameters): LiveData<Contacts> = contactsLiveData | |
} | |
class ContactsViewModelFactory(val getContactsUseCase: GetContactsUseCase, val parameters: Parameters) | |
: ViewModelProvider.Factory { | |
override fun <T : ViewModel> create(modelClass: Class<T>): T { | |
return ContactsViewModel(getContactsUseCase, parameters) as T | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment