Hi! I am using moko livedata (version 0.10.1) with...
# moko
z
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
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
updates will work only if databinding have setted lifecycle. https://developer.android.com/topic/libraries/data-binding/architecture#livedata
z
Thanks for your explanation! I did more experiment and found
.ld
works fine, while
.ld()
does not.