suspend Handler
Registers a suspend handler for event type T and returns a Subscription token.
The subscription is registered synchronously before returning. Events can be posted immediately after this call returns without any timing concerns.
val sub = bus.suspendHandler<PlayerJumpEvent> { e ->
delay(100)
println(e.player)
}
sub.cancel()Parameters
Dispatch priority; defaults to Priority.NORMAL.
Controls concurrency when events arrive faster than handlers complete.
Coroutine scope for handler execution. When null (default), an internal scope is created and cancelled when the subscription is cancelled. When an explicit scope is provided, it is used but never cancelled by this subscription - the caller retains full lifecycle ownership. Prefer providing an explicit scope in production code.
The suspend function invoked for each matching event.
Registers a suspend handler for event type T on this TypedEventBus and returns a Subscription token.
Delegates to EventBus.suspendHandler on the underlying bus.
val networkBus = EventBus().typed<NetworkEvent>()
val sub = networkBus.suspendHandler<PacketReceived>(scope = viewModelScope) { e ->
delay(100)
handle(e)
}
sub.cancel()Parameters
Dispatch priority; defaults to Priority.NORMAL.
Controls concurrency when events arrive faster than handlers complete.
Coroutine scope for handler execution. When null (default), an internal scope is created and cancelled when the subscription is cancelled. When an explicit scope is provided, it is used but never cancelled by this subscription - the caller retains full lifecycle ownership. Prefer providing an explicit scope in production code.
The suspend function invoked for each matching event.