A Delegated Property that is also an RxJava Observable.
Code:
val fooProperty = RxProperty("initial")
var foo by fooProperty
fooProperty.subscribe(::println)
foo = "hello"
foo = "hello"
foo = "world"
Output:
hello
hello
world
You can add this project as a dependency via JitPack.
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
dependencies {
compile 'io.github.snarks:RxProperty:1.0'
}
(com.github.snarks
will also work)
- It will never emit
onError
oronComplete
- It will emit
onNext
immediately after a value is assigned to it - It does not operate by default on a particular
Scheduler
It's not safe to assign values to RxProperty
from multiple threads, but the usual RxJava operations are thread-safe.