is there a convenience method that converts a `Mon...
# coroutines
t
is there a convenience method that converts a
Mono
into a
Deferred
? I can see we can transofrm it into a
Flow
which feels wrong as the
Mono
provides at most one value
d
At most? If it's not exactly one value, then
Deferred
also seems wrong.
t
well no. it IS excactly one value if successful: `A Reactive Streams 
Publisher
 with basic rx operators that completes successfully by emitting an element, or with an error.`
d
Ah. (I'm not very familiar with Rx). But there's probably a
Mono.await()
suspend function or similar. It is discouraged to use the
Deferred
type, you just suspend instead (where possible).
☝️ 1
Just read the docs. It's called
awaitSingle()
.
a
Deferred
is more of a future, it's an operation already in flight. It's hot, not cold
☝🏼 1
s
Depends, when started with
LAZY
, a Deferred is cold (but it's a 'shared' Mono/Single, since calling await() again won't restart the operation).
a
You can expose that same behavior as a suspend fun though, and just like a Single the shared/not shared nature of it is an implementation detail.
t
alright i understand. thanks for your input 🙂