Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Methods inside ViewModel to grab two LiveData from repository and put them into one MediatorLiveData
fun getSubjects(): LiveData<List<Subject>>? {
return sroRepository.getSubjects()
}
fun getReminders(): LiveData<List<Reminder>>? {
return sroRepository.getReminders()
}
fun getAllData(): CombinedSubjectReminders? {
var ldSubjects = getSubjects()
var ldReminders = getReminders()
if (ldSubjects != null && ldReminders != null) {
return CombinedSubjectReminders(ldSubjects, ldReminders)
}
return null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.