kotlin-flow-extensions / hu.akarnokd.kotlin.flow / SubjectAPI

SubjectAPI

interface SubjectAPI<T> : FlowCollector<T>

Base interface for suspendable push signals emit, emitError and complete.

Functions

collectorCount

abstract fun collectorCount(): Int

Returns the number of collectors waiting for data.

complete

abstract suspend fun complete(): Unit

Indicate no further items will be produced.

emitError

abstract suspend fun emitError(ex: Throwable): Unit

Signal an Throwable to the collector.

hasCollectors

abstract fun hasCollectors(): Boolean

Returns true if this subject has collectors waiting for data.

Inheritors

BehaviorSubject

class BehaviorSubject<T> : AbstractFlow<T>, SubjectAPI<T>

Caches one item and replays it to fresh collectors.

PublishSubject

class PublishSubject<T> : AbstractFlow<T>, SubjectAPI<T>

Multicasts items to any number of collectors when they are ready to receive.

ReplaySubject

class ReplaySubject<T> : AbstractFlow<T>, SubjectAPI<T>

Caches and replays some or all items to collectors.