EventBus

interface EventBus

Event publishing and subscription.

Key constraints

  • No dependency on a real server runtime.

  • No assumptions about threading: platforms decide what "sync" means.

  • Subscription is type-based and capability-oriented (e.g. Cancellable).

Implementations should be deterministic and test-friendly.

Functions

Link copied to clipboard
abstract fun <E : Event> post(event: E): E

Publishes an event to all listeners.

Link copied to clipboard
open fun <E : Event> subscribe(type: Class<E>, listener: EventListener<E>): EventSubscription

Java-friendly overload: defaults to EventPriority.NORMAL, not ignoring cancelled events.

open fun <E : Event> subscribe(type: Class<E>, priority: EventPriority, listener: EventListener<E>): EventSubscription

Java-friendly overload: defaults to not ignoring cancelled events.

abstract fun <E : Event> subscribe(type: Class<E>, listener: EventListener<E>, priority: EventPriority, ignoreCancelled: Boolean): EventSubscription

Subscribes a listener for a specific event type.

Link copied to clipboard
inline fun <E : Event> EventBus.subscribe(priority: EventPriority = EventPriority.NORMAL, ignoreCancelled: Boolean = false, noinline listener: (E) -> Unit): EventSubscription

Kotlin convenience overload.