listen

abstract suspend fun <T : Any> listen(handler: HandlerCoroutines<T>): AutoCloseable

Registers a handler to listen for messages of a specific type.

Return

an AutoCloseable that can be used to unregister the handler.

Parameters

T

the type of the message to listen for.

handler

the handler to process incoming messages.


abstract suspend fun <T : Any> listen(type: KClass<T>, handler: suspend (T) -> Unit): AutoCloseable

Registers a handler to listen for messages of a specific type.

Return

an AutoCloseable that can be used to unregister the handler.

Parameters

T

the type of the message to listen for.

type

the KClass representing the type of the message.

handler

the suspend function to process incoming messages.