https://kotlinlang.org logo
#android
Title
# android
o

Ofir Bar

03/17/2020, 10:11 AM
My Activity observers 3 `MutableLiveData`in a
ViewModel
. I change their values one after another:
Copy code
advertisementGoal.value = editModeInitialAdvertisement!!.goal
advertisementTargetUserType.value = editModeInitialAdvertisement!!.userTypeTarget
selectedExpertiseField.value = editModeInitialAdvertisement!!.expertiseField.id
Is this a race condition? or do
LiveData
in the UI trigger
onChange()
in order?
a

Araib

03/17/2020, 1:34 PM
This will actually call
setValue()
for
LiveData
and as per my understanding
setValue()
gets triggered almost instantly so no race condition should happen. It could be that if you used
postValue()
of
LiveData
then a race condition could happen since
postValue()
runs on background thread. I might be wrong here though so please feel free to correct me..
👍 1
4 Views