JakeWharton / RxRelay

RxJava types that are both an Observable and a Consumer.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Behavior Relay accept Nullable Type in Kotlin

springwong opened this issue · comments

Is it possible that BehaviorRelay accept nullable type in kotlin and pass null in accept() or createDefault()?
val relay: BehaviorRelay<String?> = BehaviorRelay.createDefault(null)
or
relay.accept(null)

Now, it will throw NullPointerException if pass any null value into BehaviorRelay.

RxJava 2 Subjects are not tolerant of nulls and so Relays are not tolerant of them either. You would never be able to propagate the null to any subscriber anyway since the RxJava internals also would prevent you.