listen

inline fun <T : Event> listen(priority: EventPriority = EventPriority.NORMAL, ignoreCancelled: Boolean = false, once: Boolean = false, delay: Long = 0, debounce: Long = 0, throttle: Long = 0, async: Boolean = false, crossinline scope: EventScope<T>.() -> Unit = {}, noinline filter: (T) -> Boolean = { true }, noinline block: (T) -> Unit): EventHandle

Registers a listener for the specified event type T.

This function allows listening to events with configurable parameters such as priority, cancellation behavior, async execution, delay, throttle, debounce, and more.

Return

An EventHandle that can be used to unregister the event listener.

Parameters

priority

The priority at which the event is handled.

ignoreCancelled

Whether or not the event is ignored if it is cancelled.

once

If true, the listener will automatically unregister after it is triggered once.

delay

The delay in milliseconds before the event is handled.

debounce

The debounce time in milliseconds for event handling.

throttle

The throttle time in milliseconds to limit the frequency of event handling.

async

Whether the event should be handled asynchronously.

scope

The scope of the event listener, where conditions for the event can be defined.

filter

A filter function to determine if the event should be handled.

block

The block of code to execute when the event is triggered.


inline fun <T : Event> EventGroup.listen(priority: EventPriority = EventPriority.NORMAL, ignoreCancelled: Boolean = false, once: Boolean = false, delay: Long = 0, debounce: Long = 0, throttle: Long = 0, async: Boolean = false, crossinline scope: EventScope<T>.() -> Unit = {}, noinline filter: (T) -> Boolean = { true }, noinline block: (T) -> Unit)

Registers a listener for the specified event type T within the context of an EventGroup.

This function allows adding listeners to an event group for batch management.

Parameters

priority

The priority at which the event is handled.

ignoreCancelled

Whether or not the event is ignored if it is cancelled.

once

If true, the listener will automatically unregister after it is triggered once.

delay

The delay in milliseconds before the event is handled.

debounce

The debounce time in milliseconds for event handling.

throttle

The throttle time in milliseconds to limit the frequency of event handling.

async

Whether the event should be handled asynchronously.

scope

The scope of the event listener, where conditions for the event can be defined.

filter

A filter function to determine if the event should be handled.

block

The block of code to execute when the event is triggered.