My Activity observers 3 `MutableLiveData`in a `Vie...
# android
o
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
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