ReplaySubject

@FlowPreview()
class ReplaySubject<T> : AbstractFlow<T> , SubjectAPI<T>

Caches and replays some or all items to collectors.

Constructors

ReplaySubject
Link copied to clipboard
fun ReplaySubject()
Creates a ReplaySubject with an unbounded internal buffer caching all values received via emit.
ReplaySubject
Link copied to clipboard
fun ReplaySubject(maxSize: Int)
Creates a ReplaySubject that caches at most maxSize values to be replayed to late collectors.
ReplaySubject
Link copied to clipboard
fun 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
Link copied to clipboard
fun 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
Link copied to clipboard
fun 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.

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 current number of collectors.
collectSafely
Link copied to clipboard
@FlowPreview()
open suspend override fun collectSafely(collector: FlowCollector<T>)
Accepts a collector and emits the cached values upfront and any subsequent value received by this ReplaySubject until the ReplaySubject gets terminated.
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)
Emit a value to all current collectors when they are ready.
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 PublishSubject has any collectors.