I am trying to combine dataBinding with RxJava so that it looks something like that:
layout.xml:
<android.support.constraint.ConstraintLayout
//...
app:rxClick="@{viewModel.onTap}">
<TextView
//...
android:text="@{viewModel.title}"
</TextView>
//...
ViewModel:
class ViewModel {
val title = PublishSubject.create<String>()
val onTap = PublishSubject.create<Void>()
//...
}
But I cannot find an easy way to make it like that.
One of the things I found while researching is ObservableField and LiveData which is included in the dataBinding library. And I do not think it is a good solution because rxJava is much more sophisticated and ObservableField does not seem to be compatible with rxJava.
Another thing I found is this library https://github.com/ArthurVimond/RxBindingAdapters which kind of suits the case. But it does not work, failing with the error while compiling:
e: [kapt] An exception occurred: android.databinding.tool.util.LoggedErrorException: Found data binding errors.
****/ data binding error ****msg:cannot find type element for io.reactivex.subjects.Subject
Is there another option I missed? Any suggestions?