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"))
Functions
next
Link copied to clipboard
off
Link copied to clipboard
Unsubscribes the action for all events.
on
Link copied to clipboard
Inheritors
Extensions
next
Link copied to clipboard
inline fun <E : Event> EventEmitter<Event>.next(noinline action: (E) -> Unit)
Content copied to clipboard
inline fun <E : PlayerEvent> EventEmitter<PlayerEvent>.next(noinline action: (E) -> Unit)
Content copied to clipboard
inline fun <E : SourceEvent> EventEmitter<SourceEvent>.next(noinline action: (E) -> Unit)
Content copied to clipboard
on
Link copied to clipboard
inline fun <E : Event> EventEmitter<Event>.on(noinline action: (E) -> Unit)
Content copied to clipboard
inline fun <E : PlayerEvent> EventEmitter<PlayerEvent>.on(noinline action: (E) -> Unit)
Content copied to clipboard
inline fun <E : SourceEvent> EventEmitter<SourceEvent>.on(noinline action: (E) -> Unit)
Content copied to clipboard