ReceiveChannel.asFlow operator
See original GitHub issueA missing piece of the Flow puzzle is a connection between regular ReceiveChannel
and Flow
(note that we already have a pretty non-obvious ReceieveChannel.asFlux
) with a proper migration path for channel operators.
For example, all operators on top of the channels are deprecated, but users have no clear migration path from their channel operators sequence to flow.
The main focus here is to provide clear consumption semantics and decide whether we want to introduce such primitive at all
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:5 (5 by maintainers)
Top Results From Across the Web
asFlow - Kotlin
Creates a cold flow that produces values from the given array. The flow being cold means that the array components are read every...
Read more >Going deep on Flows & Channels — Part 2 - ProAndroidDev
These operators don't execute code against the flow, instead, ... There are others, like flowOf() or asFlow(), so you can check them if...
Read more >Change log for kotlinx.coroutines
Cancellation from flat* operators that leverage multiple coroutines is no longer ... asFlow propagates coroutine context from collect call to the Publisher.
Read more >From Zero To Hero Series ( Kotlin Sequences, Channels ...
Various collections and sequences can be converted to flows using asFlow() extension functions. Flow example 5 — Intermediate Flow Operators.
Read more >Co-routine flow wrapper - CommonsWare
I have an extension operator on ReceiveChannel. Can I move that extension operator ... BroadcastChannel has an asFlow() extension function.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The proposal is to name it
consumeAsFlow
and add additional precaution that repeated attempts to collect from the resulting flow produceIllegalStateException
just in case. See https://github.com/Kotlin/kotlinx.coroutines/blob/bc34a2e0d136d3635f6413c0e7885cf7f527f857/kotlinx-coroutines-core/common/src/flow/Channels.kt#L17-L29You are right, @elizarov, I confused this use case with the example https://github.com/Kotlin/kotlinx.coroutines/issues/1326#issuecomment-509144702 , in that case
asFlow
drops messages (and so on… see other issue).