FlowBus

@API(status = API.Status.EXPERIMENTAL, since = "5.0.0")
open class FlowBus

This class holds all state flows and handles event posting. You can use the Koin singleton that is just plain instance of this class or create your own implementation.

Constructors

Link copied to clipboard
fun FlowBus()

Functions

Link copied to clipboard
fun dropAll()

Removes all retained events

Link copied to clipboard
fun <T : Any> dropEvent(clazz: KClass<T>)

Removes retained event of type clazz

Link copied to clipboard
@API(status = API.Status.INTERNAL)
open fun <T : Any> forEvent(clazz: KClass<out T>): RendezvousStateFlow<T?>
Link copied to clipboard
fun <T : Any> getFlow(clazz: KClass<T>): Flow<T>

Gets a Flow for events of the given type.

Link copied to clipboard
fun <T : Any> getLastEvent(clazz: KClass<T>): T?

Returns last posted event that was instance of clazz or null if no event of the given type is retained.

Link copied to clipboard
fun <T : Any> post(event: T, retain: Boolean = false)

Posts a new event to StateFlow of the event type.

Link copied to clipboard
suspend fun <T : Any> postDeferred(event: T, retain: Boolean = false): Deferred<Unit>
Link copied to clipboard
inline fun <T : Any> postLazy(retain: Boolean = false, lazyEvent: () -> T)

Extensions

Link copied to clipboard
inline fun <T : Any> FlowBus.dropEvent()
Link copied to clipboard
inline fun <T : Any> FlowBus.getFlow(): Flow<T>
Link copied to clipboard
inline fun <T : Any> FlowBus.getLastEvent(): T?