rx-observablefield

Additional

Language
Kotlin
Version
N/A
Created
Aug 16, 2017
Updated
Jul 4, 2018 (Retired)
Owner
chuross
Contributor
chuross
1
Activity
Badge
Generate
Download
Source code

Rx ObservableField

DataBinding converter library for RxJava2. This Library provide ObservableField to convert RxJava2.

Download

  1. add JitPack repository to your project root build.gradle.
repositories {
    maven { url "https://jitpack.io" }
}
  1. add the dependency latest version:
dependencies {
    compile 'com.github.chuross.rx-observablefield:rxobservablefield:x.x.x'
}
  1. (optional) add the dependency for kotlin:
dependencies {
    compile 'com.github.chuross.rx-observablefield:rxobservablefield-kotlin:x.x.x'
}

Usage

kotlin

val disposables = CompositeDisposables() // RxJava2#CompositeDisposables

...

val hogeField = RxObservableField<String>()

// ObservableField -> Rx#Observable + Operators -> ReadOnlyRxObservableField
val hogeLengthField = hogeField.rx.map { it.length }.filter { it > 10 }.toObservableField(disposables) // ReadOnly!
val hogeLengthField = hogeField.rx.map { it.length }.filter { it > 10 }.toObservableField(disposables, default = 0) // ReadOnly!(with default value)


// get value
hogeField.get() // String?
hogeField.or("fuga") // String