subscribeAll

abstract fun subscribeAll(priority: Int, handler: (Event) -> Unit): Subscription

Registers a wildcard handler that fires for every event posted to this bus, regardless of type. Returns a Subscription token for removal.

Wildcard handlers are merged into the same priority-sorted dispatch list as typed handlers. A wildcard at Priority.HIGHEST fires before typed handlers at Priority.NORMAL; a wildcard at Priority.LOWEST fires after. Cancellation mid-list stops both wildcard and typed handlers uniformly.

Kotlin:

val sub = bus.subscribeAll(Priority.HIGHEST) { e -> validate(e) }
val log = bus.subscribeAll(Priority.LOWEST) { e -> logger.debug("{}", e) }
sub.cancel()

Java:

Subscription sub = bus.subscribeAll(Priority.NORMAL, e -> log(e));
sub.cancel();

Return

A Subscription whose Subscription.cancel removes this wildcard handler.

Parameters

priority

Dispatch priority; interleaves with typed handlers.

handler

Lambda receiving every posted event as Event.


open fun subscribeAll(priority: Int, handler: Consumer<Event>): Subscription

Java-facing wildcard handler registration. Kotlin callers use the subscribeAll extension which provides a default Priority.NORMAL value.

bus.subscribeAll(Priority.NORMAL, e -> log(e));