EventChannel

interface EventChannel<out T : Event>

Generic event channel that allows registration of listeners that will be called when an event is published via an appropriate EventPublisher.

Important: This is a Public Preview API. It may be changed or removed at any time.

Functions

Link copied to clipboard
abstract fun register(listener: EventListener<T>)

Registers an EventListener which will be notified about published events.

Link copied to clipboard
abstract fun unregister(listener: EventListener<T>)

Unregisters the given EventListener.

Inheritors

Link copied to clipboard
Link copied to clipboard

Extensions

Link copied to clipboard
suspend fun <T : Event> EventChannel<T>.awaitEvent(awaitedEvent: T): T

Waits till provided event appears in the EventChannel

Link copied to clipboard
fun <T : Event> EventChannel<T>.registerOneShotListener(filter: (T) -> Boolean = { true }, block: (T) -> Unit): Disposable

Registers EventListener that will be called only one time and only when given condition is met. Optional filter can be used to make the listener triggered only for certain events based on provided criteria. By default, all events are accepted. Once the listener is triggered, it will remove itself from this EventChannel automatically.