Mgj
07/07/2020, 1:44 PMStateFlow
or MutableStateFlow
properties? I've created custom binding adapters before, but i cannot get it to work properly with StateFlowslouiscad
07/07/2020, 7:42 PMMgj
07/08/2020, 8:16 AM@InverseBindingAdapter(attribute = "flowText")
@JvmStatic
fun getText(view: MyEditText): String {
return view.text.toString()
}
@BindingAdapter("flowText")
@JvmStatic
fun setText(view: MyEditText, newValue: String) {
if (view.text.toString != newValue) {
view.text = newValue
view.textChangedListener?.onChange()
}
}
@BindingAdapter("flowTextAttrChanged")
@JvmStatic
fun setListeners(
view: MyEditText,
attrChange: InverseBindingListener
) {
view.textChangedListener = attrChange
}
But when replacing String
with MutableStateFlow<String>
the InverseBindingAdapter would never be called or used by the generated binding codeOrhan Tozan
07/08/2020, 9:52 AMMgj
07/08/2020, 11:04 AMlouiscad
07/08/2020, 11:22 AMflow.asLiveData()
Mgj
07/08/2020, 11:27 AMOrhan Tozan
07/08/2020, 11:27 AMMgj
07/08/2020, 11:28 AMasLiveData
is neat, but i cant seem to find a asMutableLiveData... Seems like i'd still have to make bindingAdapter-like code to enable two-way bindinglouiscad
07/08/2020, 3:07 PMasMutableLiveData
if you want.Mgj
07/08/2020, 3:08 PM