https://kotlinlang.org logo
#rx
Title
# rx
u

ursus

05/21/2020, 2:42 AM
is there a safer operator I can use, which would give me the latest value or null, sort of like
BehaviorRelay.value
?
z

Zach Klippenstein (he/him) [MOD]

05/21/2020, 3:24 AM
You can
amb
your upstream with
Observable.just(NO_VALUE)
(where
NO_VALUE
is some sentinel value that makes sense with your types). If you put the sentinal last in the list of arguments to
amb
, you’ll get the behavior you want.
u

ursus

05/21/2020, 3:30 AM
wouldnt the
just
always win?
oh as a last arg, I see, thanks!
z

Zach Klippenstein (he/him) [MOD]

05/21/2020, 4:16 AM
Yep, if all the arguments emit synchronously then the winner depends on order in the list.
u

ursus

05/21/2020, 5:10 AM
sweet
2 Views