Closed funct7 closed 3 years ago
Hi @funct7 Unfortunately no. Under the hood FIFO queue is used to manage receivers, and new value is received by first registered "listener" (in iteration every new loop is a new "listener"). You can have several iterators for CoChannel
and if first iterator is "busy" with processing received value, then second iterator
will receive the new value. CoChannel
is thread safe and you can be sure that different iterators for the same channel will not receive the same value. It make possible to perform different "read/receive" operations with channel in parallel.
Your idea is the complete opposite 😀 I think you are looking something similar to Kotlin's BroadcastChannel. I wanted to implement that but now I don't see any sense to add new features to this library (except bug fixes) because of Apple's async/await release.
I can only give you advice to create you own wrapper around CoChannel (if you really need it) and implement it by yourself 🙂
It's understandable. Thank you for the reply.
I have two objects that call
makeIterator()
on the same instance of aCoChannel
, and only the first caller is receiving values:It seems like all the methods on a
CoChannel
only allow consuming the value (remove and return), and I'm guessing that may be the reason the second observer never receives anything.Is it possible to just peek, and therefore allow have multiple observers, like
Observable
of Rx orSharedFlow
of Kotlin coroutine?