EventNode

interface EventNode<T : Event>

A single node in an event tree.

A node may contain any number of children and/or listeners. When an event is called on a node, the node will first check if it has any listeners for the event, calling those first, then the event will propagate down the tree to all children of the node, in order of their priority.

If an event in the tree is cancelled, it will not propagate to any other nodes, and its dispatching will be considered complete. No further event listeners will receive the event.

Every event node has a name, which should be uniquely identifiable, and will be useful for debugging, as well as identifying the node in the tree.

Inheritors

Types

Link copied to clipboard
object Companion
Link copied to clipboard
@ApiStatus.Internal
interface Factory

Functions

Link copied to clipboard
abstract fun addChild(node: EventNode<out T>)

Adds the given node as a child of this event node.

Link copied to clipboard
abstract fun <E : T> fire(event: E): E

Fires the given event on this event node.

Link copied to clipboard
abstract fun hasListener(type: Class<out T>): Boolean

Checks if this event node has a listener for the given event type.

Link copied to clipboard
abstract fun registerListener(listener: EventListener<out T>)

Registers the given event listener to this event node.

open fun <E : T> registerListener(eventType: Class<E>, handler: Consumer<E>)

Registers an event listener for the given eventType to this event node, calling the given handler when the event is fired.

Link copied to clipboard
inline fun <T : Event, E : T> EventNode<T>.registerListener(handler: Consumer<E>)

Registers an event listener for the given event type T to this event node, calling the given handler when the event is fired.

Link copied to clipboard
abstract fun registerListeners(listenerClass: Any)

Registers all event listeners in the given listenerClass to this event node.

Link copied to clipboard
abstract fun removeChild(node: EventNode<out T>)

Removes the given node as a child of this event node.

Link copied to clipboard
abstract fun unregisterListener(listener: EventListener<out T>)

Unregisters the given event listener from this event node, meaning it will not be called when an event that it listens for is fired.

Link copied to clipboard
abstract fun unregisterListeners(listenerClass: Any)

Unregisters all listeners in the given listenerClass from this event node.

Properties

Link copied to clipboard
abstract val children: Set<EventNode<T>>

The children of this node.

Link copied to clipboard
abstract val eventType: Class<T>

The type of events this node can have listeners for.

Link copied to clipboard
abstract val name: String

The name of this node.

Link copied to clipboard
abstract val parent: EventNode<in T>?

The parent of this node.

Link copied to clipboard
abstract var priority: Int

The priority of this node.