miqbaldc
03/15/2022, 5:02 AMsingle
is equivalent to first
?
There’s seems a weird issue in my part. When using single
it returns null
, but exist otherwise with first
Nick Allen
03/15/2022, 5:19 AMsingle
will wait for the Flow
to finish in the successful case and throw if there was more than just the one item unlike first
.ephemient
03/15/2022, 7:59 AMflow {
emit(1)
emit(2)
delay(1_000_000)
}.single()
doesn't wait for the delay because it can throw as soon as 2 is emittedephemient
03/15/2022, 8:01 AMsingle
function on Iterable and Sequenceephemient
03/15/2022, 8:03 AMsequence {
yield(1)
yield(2)
println("unreachable")
}.single()
Nick Allen
03/15/2022, 3:47 PM