MessageHandler

constructor(messageBus: MessageBus, scope: CoroutineScope, topic: Topic<T>, handleError: suspend (Throwable) -> Unit = {}, handleMessage: suspend (message: T) -> Unit)

Parameters

messageBus

The MessageBus instance the handler subscribes to.

scope

The CoroutineScope in which the handler operates.

topic

The Topic that the handler subscribes to for receiving messages.

handleError

Function for handling errors that occur during execution of handleMessage. Errors do not cause the flow to complete.

handleMessage

A suspending function invoked for each received message associated with the given topic.

Type Parameters

T

The type of messages to handle, constrained to non-nullable types.