Conceptually yes, but the second code is hot, too....
# coroutines
e
Conceptually yes, but the second code is hot, too. Coroutine still runs. For an example of a cold stream try
sequence { }
. It is truly cold. But it is synchronous. We don’t have async cold streams yet.
v
But technically in the second example the custom element is not produces until it is required, right? Maybe it is good a way to emulate a cold steam with a hot stream so that we don't need cold streams as a separate concept.
e
You cannot. It is still hot. The code in coroutine runs even before you invoke receive.
k
I’m a little unclear about the analogy of hot/cold in this context as well. Typically, if there is no buffer, the producer will wait until a consumer eats whatever was sent last, so it is sort of depending on someone consuming it before moving on to the next emission. Is it hot, in that it’s pushing new elements by itself as soon as there’s a “buffer” space? Or could it be considered cold using my description above
e
It is cold if it does not consume any resources until you start consuming/receiving from it (running coroutine is a resource).
👍 2