MulticastSubject

@FlowPreview()
class MulticastSubject<T>(expectedCollectors: Int) : AbstractFlow<T> , SubjectAPI<T>

A subject implementation that awaits a certain number of collectors to start consuming, then allows the producer side to deliver items to them.

Parameters

the element type of the [Flow]
bufferSize

the number of items to buffer until consumers arrive

Constructors

MulticastSubject
Link copied to clipboard
fun MulticastSubject(expectedCollectors: Int)
the element type of the [Flow]

Types

Companion
Link copied to clipboard
object Companion

Functions

collect
Link copied to clipboard
suspend override fun collect(collector: FlowCollector<T>)
collectorCount
Link copied to clipboard
open override fun collectorCount(): Int
Returns the number of collectors waiting for data.
collectSafely
Link copied to clipboard
open suspend override fun collectSafely(collector: FlowCollector<T>)
complete
Link copied to clipboard
open suspend override fun complete()
Indicate no further items will be produced.
emit
Link copied to clipboard
open suspend override fun emit(value: T)
emitError
Link copied to clipboard
open suspend override fun emitError(ex: Throwable)
Signal an Throwable to the collector.
hasCollectors
Link copied to clipboard
open override fun hasCollectors(): Boolean
Returns true if this subject has collectors waiting for data.

Properties

collectors
Link copied to clipboard
val collectors: AtomicReference<Array<ResumableCollector<T>>>
producer
Link copied to clipboard
val producer: Resumable
remainingCollectors
Link copied to clipboard
val remainingCollectors: AtomicInteger
terminated
Link copied to clipboard
var terminated: Throwable? = null