subscribe

abstract fun subscribe(subscriber: Any)

Registers all instance methods on subscriber annotated with @Subscribe.

Calling subscribe with the same object more than once is a no-op for handlers already registered; duplicate subscriptions are not created.


abstract fun subscribe(eventClass: Class<out Event>, priority: Int, handler: (Event) -> Unit): Subscription

Kotlin-facing handler registration. Hidden from Java via @JvmSynthetic; Java callers use the java.util.function.Consumer overload below.

Kotlin callers should prefer the reified inline overload:

val sub = bus.subscribe<MyEvent> { e -> ... }

open fun <T : Event> subscribe(eventClass: Class<T>, priority: Int, handler: Consumer<T>): Subscription

Registers a java.util.function.Consumer as a handler for eventClass.

Java callers use plain void lambdas:

Subscription sub = bus.subscribe(MyEvent.class, Priority.NORMAL, e -> handle(e));

Kotlin callers should use the reified inline overload instead.