Subscription

Handle returned by lambda-based EventBus.subscribe overloads.

Call cancel to remove the handler from the bus. Implements AutoCloseable so it can be used in try-with-resources / Kotlin use { } blocks.

val sub = bus.subscribe<TickEvent> { tick() }
sub.cancel()

// Or scope it:
bus.subscribe<TickEvent> { tick() }.use { /* handler active here */}

Java:

Subscription sub = bus.subscribe(TickEvent.class, Priority.NORMAL, e -> tick());
sub.cancel();

Functions

Link copied to clipboard
abstract fun cancel()

Removes this handler from the bus. Safe to call more than once; subsequent calls are no-ops.

Link copied to clipboard
open override fun close()

Alias for cancel; satisfies AutoCloseable for try-with-resources / use { }.