artem_zin
03/29/2017, 11:26 PMcurrent()
and currentOrDefault()
for that
/**
* Emits current value and completes or completes without a value if stream has no value at the time of subscription.
*/
fun <T> Observable<T>.current() = Observable.just(Unit).withLatestFrom(this) { _, value -> value }
fun <T> Observable<T>.currentOrDefault(default: T) = this.current().defaultIfEmpty(default)
Maybe it’s even worth to add these operators to RxJava itself? cc @jw