aaverin
05/29/2020, 12:32 PMnull
is not supported by RxJava and RxKotlin, what is the strategy you use to have kind of null values?
We have some places in codebase that were doing something like
map {
service.get() //can return null
}.filterNotNull()
It's too much effort to rewrite every service to not ever return null when before null was considered a valid empty value.aaverin
05/29/2020, 12:33 PMOptional
in Kotlin kind of makes me shiver.jw
05/29/2020, 12:39 PMpawegio
05/29/2020, 12:39 PMOptional
data class Optional<out T>(val value: T?)
val <T> T?.optional get() = Optional(this)
fun <T> Observable<T>.startWithNull(): Observable<Optional<T>> = map { it.optional }.startWith(null.optional)
fun <T> Observable<Optional<T>>.filterNotNull(): Observable<T> = filter { it.isNotNull }.map { it.value!! }
aaverin
05/29/2020, 12:41 PMjw
05/29/2020, 12:43 PM