Recursive as in, the consumer of the flow can send...
# coroutines
d
Recursive as in, the consumer of the flow can send more messages to it
o
I don't think that fits the common definition of recursion, perhaps an "infinite flow" is a better term. also, do you mean "producer of the flow"? the consumer doesn't send any messages
if you do mean producer, as long as you can somehow get the data into the block of code inside of
flow { .. }
, it can send more. whether that's a channel, or a queue, or a socket doesn't really matter, it just has to come to get to that block so it can be `emit`ted
b
bi-directional data flow 🙂 Channel is the only idiomatic way I can think of to do it. Flow is a fairly uni-directional data stream.
d
Yeah, I mean consumer. Like, the consumer reads data off the flow but can feed more into it, the same way a function might recursively invoke itself
@bdawg.io Thanks, I figured as much.
Channels
aren't going away then? Just the fluent/builder API is moving toward flows?
b
just the intermediate operators on channels are being removed in favor of the operators on flows.
Copy code
channel.map { it * 2 }
becomes
Copy code
channel.asFlow().map { it * 2 }
d
aha. borrowing
.stream()
from JDK8 I see
(sorry, snark is my first language)
b
Pretty much without the downsides to JDK8 streams plus complete coroutines support 🙂