@FlowPreview class ReplaySubject<T> : AbstractFlow<T>, SubjectAPI<T>
Caches and replays some or all items to collectors.
ReplaySubject()
Creates a ReplaySubject with an unbounded internal buffer caching all values received via emit. ReplaySubject(maxSize: Int)
Creates a ReplaySubject that caches at most maxSize values to be replayed to late collectors. ReplaySubject(maxTime: Long, unit: TimeUnit)
Creates a ReplaySubject that caches values at most for the given maxTime real-time duration and replays those upfront to late collectors. ReplaySubject(maxSize: Int, maxTime: Long, unit: TimeUnit)
Creates a ReplaySubject that caches at most maxSize values at most for the given maxTime real-time duration and replays those upfront to late collectors. ReplaySubject(maxSize: Int, maxTime: Long, unit: TimeUnit, timeSource: (TimeUnit) -> Long)
Creates a ReplaySubject that caches at most maxSize values at most for the given maxTime duration (measured via the custom timeSource) and replays those upfront to late collectors. |
suspend fun collectSafely(collector: FlowCollector<T>): Unit
Accepts a collector and emits the cached values upfront and any subsequent value received by this ReplaySubject until the ReplaySubject gets terminated. |
|
fun collectorCount(): Int
Returns the current number of collectors. |
|
suspend fun complete(): Unit
Indicate no further items will be produced. |
|
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 Throwable to the collector. |
|
fun hasCollectors(): Boolean
Returns true if this PublishSubject has any collectors. |