Skip to content
RxJava2 extensions for Android Databindings library
Branch: master
Clone or download
steelrooter and stepango Add explicit Observable return types (#26)
* Specify explicit return type of Observable

* Use method references

* Allow only non-nullable Observables

* Bump version to 1.9.0
Latest commit bcc4e86 Jul 2, 2019

README.md

RxDatabindings

Download

RxJava2 extensions for Android Databindings library

Add RxDataBindings to your build.gradle

implementation "com.stepango.rxdatabindings:rxdatabindings:1.9.0"

Basic example of usage:

interface ViewModelState : Parcelable {
    val text: ObservableString
    val counter: ObservableInt
}

data class ViewModelStateImpl(
        override val text: ObservableString = ObservableString(),
        override val counter: ObservableInt = ObservableInt()
) : ViewModelState, AutoParcelable

class ViewModel(val state: ViewModelState) : ViewModelState by state {

    init {
        counter.observe()
                .setTo(text) { "Wow! You count till $it" }
                .doOnNext { Log.d("THREAD", Thread.currentThread().name) }
                .subscribe()
    }

    fun incCounter() = counter.inc(10)
    fun decCounter() = counter.dec(0)

}
You can’t perform that action at this time.