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 */}Content copied to clipboard
Java:
Subscription sub = bus.subscribe(TickEvent.class, Priority.NORMAL, e -> tick());
sub.cancel();Content copied to clipboard