typed

fun <E : Event> EventBus.typed(rootClass: Class<E>): TypedEventBus<E>

Returns a TypedEventBus view over this bus restricted to subtypes of E.

The returned bus shares the underlying handler registry; handlers registered on either the typed view or the original bus are visible to both.

Java callers pass a class token for type inference:

TypedEventBus<NetworkEvent> bus =
TypedEventBusFactory.typed(underlying, NetworkEvent.class);

Parameters

rootClass

Unused at runtime (erased); present only to satisfy Java's type inference.


inline fun <E : Event> EventBus.typed(): TypedEventBus<E>

Returns a TypedEventBus view over this bus restricted to subtypes of E.

The returned bus shares the underlying handler registry; handlers registered on either the typed view or the original bus are visible to both.

val networkBus = EventBus().typed<NetworkEvent>()
networkBus.post(PacketReceived(bytes))