I'm learning Data Binding by reading up on the official docs. Everything makes sense expect the possible infinite loops in the two-way binding. As per the official docs on two-way binding:
Be careful not to introduce infinite loops when using two-way data binding. When the user changes an attribute, the method annotated using @InverseBindingAdapter is called, and the value is assigned to the backing property. This, in turn, would call the method annotated using @BindingAdapter, which would trigger another call to the method annotated using @InverseBindingAdapter, and so on.
I understand first part of the statement that the method annotate with @InverseBindingAdapter
will be called if the attribute is changed and new value is assigned to the backing property.
But what I don't understand is why @InverseBindingAdapter
method is called again when @BindingAdapter
method is called in this process and how it leads to infinite loops?