@FlowPreview class BehaviorSubject<T> : AbstractFlow<T>, SubjectAPI<T>
Caches one item and replays it to fresh collectors.
BehaviorSubject()
Constructs an empty BehaviorSubject. BehaviorSubject(initialValue: T)
Constructs a BehaviorSubject with an initial value to emit to collectors. |
suspend fun collectSafely(collector: FlowCollector<T>): Unit
Accepts a collector and emits the latest (if available) value and any subsequent value received by this BehaviorSubject until the BehaviorSubject gets terminated. |
|
fun collectorCount(): Int
Returns the number of collectors waiting for data. |
|
suspend fun complete(): Unit
Signal current and future collectors that no further values will be coming. |
|
suspend fun emit(value: T): Unit
Emit a value to all current collectors when they are ready. |
|
suspend fun emitError(ex: Throwable): Unit
Signal an exception to all current and future collectors when they are ready. |
|
fun hasCollectors(): Boolean
Returns true if this subject has collectors waiting for data. |