Created
April 20, 2020 08:03
-
-
Save hafizrahman/52afaee41a02497e48f77086b28f78c9 to your computer and use it in GitHub Desktop.
Methods inside ViewModel to grab two LiveData from repository and put them into one MediatorLiveData
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
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