listen

inline suspend fun <T : Any> BrokerCoroutines.listen(noinline 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.

handler

the suspend function to process incoming messages.