Mathias Brandt
06/27/2018, 11:16 AMLiveData<List<Match>>
object in my ViewModel, and I observe the list in my view.
The Match
objects in the list come from a network source, one at a time. So I never set the entire list at once, but rather I add a single Match
to the list when I receive it. This is my solution so far, when I receive a new Match
object:
val matches = liveMatches.value?.toMutableList() ?: mutableListOf()
matches.add(newMatch)
liveMatches.value = matches
It seems to work, but I am worried about simultaneous updates. Don’t I risk missing some objects because of a race condition with this approach?