https://kotlinlang.org logo
#moko
Title
# moko
z

Zhiqiang Bian

07/14/2021, 9:36 PM
Hi! I am using moko livedata (version 0.10.1) with databinding in layout.xml. Can I ask how to refer to a LiveData as shown in the screenshots below? I tried
android:text="viewModel.station.ld().name"
and
android:text="viewModel.station.ld.name"
. The initial value can be read correctly, but it never updates.
y

y9san9

07/15/2021, 3:49 AM
Despite of the IDE highlighting, try to compile this 🙂
👍 1
I came across this issue resently and this compiles fine, I think the reason is that there is also LiveData in common code that has no
ld()
method
a

alex009

07/15/2021, 1:38 PM
updates will work only if databinding have setted lifecycle. https://developer.android.com/topic/libraries/data-binding/architecture#livedata
z

Zhiqiang Bian

08/02/2021, 1:58 PM
Thanks for your explanation! I did more experiment and found
.ld
works fine, while
.ld()
does not.
9 Views