Listenable

interface Listenable<E>(source)

Interface for objects that support listener-based event observation.

This interface provides a mechanism to register and unregister listeners that will be notified when events of type E occur. It follows the observer pattern and is designed to be used with event-driven architectures.

Parameters

E

The type of event that listeners will receive

Inheritors

Functions

Link copied to clipboard
abstract fun addListener(listener: Listener<E>)

Registers a listener to receive events.

Link copied to clipboard
fun <E> Listenable<E>.asFlow(): Flow<E>

Converts this Listenable into a Flow that emits events.

Link copied to clipboard
abstract fun removeListener(listener: Listener<E>)

Unregisters a listener from receiving events.