Skip to content

Instantly share code, notes, and snippets.

@pedromassango
Created October 3, 2018 09:52
Show Gist options
  • Select an option

  • Save pedromassango/06ac5ddbce88f453f7845609509e5701 to your computer and use it in GitHub Desktop.

Select an option

Save pedromassango/06ac5ddbce88f453f7845609509e5701 to your computer and use it in GitHub Desktop.
//... Code removed for brevity
class MainViewModel(private val repository: Repository) : ViewModel() {
private var messageData: MutableLiveData<String>? = null
fun loadData(): LiveData<String>?{
if(messageData == null){
messageData = MutableLiveData()
}
// Getting message from repository class
messageData!!.postValue( repository.getMessage())
return messageData
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment