Event Emitter
Manages subscriptions to specific Events and notifies those subscribers when such an event is being emitted. Subscribers can be simple function types in Kotlin or EventListener implementations in Java. There are also reified versions of the EventEmitter API to allow for convenient usage from Kotlin.
Usage from Kotlin:
// Adding a new subscriber for an event
player.on(PlayerEvent.Active::class) { println("Player is active") }
player.on<PlayerEvent.Active> { println("Player is active") }
// Adding a subscriber for an event and removing it later
val onPlayerActive: (PlayerEvent.Active) -> Unit = { println("Player is active") }
player.on(onPlayerActive)
player.off(onPlayerActive)
// Adding a subscriber only for the next occurrence of an event
player.next(PlayerEvent.Active::class) { println("Player is active") }
player.next<PlayerEvent.Active> { println("Player is active") }
Usage from Java:
// Adding a new event listener for an event
player.on(PlayerEvent.Active.class, event -> System.out.println("Player is active"))
// Adding an event listener for an event and removing it later
EventListener<PlayerEvent.Active> onPlayerActive = event -> System.out.println("Player is active");
player.on(PlayerEvent.Active.class, onPlayerActive)
player.off(PlayerEvent.Active.class, onPlayerActive)
// Adding an event listener only for the next occurrence of an event
player.next(PlayerEvent.Active.class, event -> System.out.println("Player is active"))
Inheritors
Functions
Subscribes the eventListener to be executed when the next event of type E is emitted. The eventListener will then be automatically unsubscribed.
Unsubscribes the eventListener for all events.
Unsubscribes the action for all events.
Unsubscribes the eventListener for the specified event.
Unsubscribes the action for the specified event.
Subscribes the eventListener to be executed when an event of type E is emitted. Provides the same functionality as EventEmitter.on with a more convenient style when used from Java.