EventBus

object EventBus

Properties

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun initialize(vararg packageNames: String, threadPoolSize: Int = Runtime.getRuntime().availableProcessors(), isDebug: Boolean = false)

Initializes the EventBus, setting up the asynchronous executor service. Also registers a shutdown hook to cleanly shut down the executor service on application exit.

Link copied to clipboard
fun <T : Event> postAsync(event: T): T

Posts an event asynchronously.

Link copied to clipboard
fun <T : Event> postDelayed(event: T, delay: Long, timeUnit: TimeUnit, processingType: EventProcessingType): T

Posts an event to be handled after a specified delay by all registered hooks for the event's class.

Link copied to clipboard
fun <T : Event> postFullSync(event: T): T

Posts an event synchronously ensuring all handlers are executed on the calling thread.

Link copied to clipboard
fun <T : Event> postHandlerAsync(event: T): T

Posts an event synchronously.

Link copied to clipboard
fun <T : ReturnableEvent<R>, R> postReturnable(event: T, processingType: EventProcessingType): R?

Posts an event to be handled synchronously by all registered hooks for the event's class and returns the result.

Link copied to clipboard
fun <T : Event> postWithCallback(event: T, callback: (T) -> Unit, delay: Long?, processingType: EventProcessingType): T

Posts an event to be handled asynchronously, with a callback executed upon completion.

Link copied to clipboard
fun <T : Event> postWithTimeout(event: T, timeout: Long, timeUnit: TimeUnit, processingType: EventProcessingType): T

Posts an event to be handled within a specified timeout by all registered hooks for the event's class.

Link copied to clipboard
fun <T : Event> processEvent(event: T, processingType: EventProcessingType): T

Processes an event based on the specified processing type.

Link copied to clipboard
fun <T : Event> registerEventHook(eventClass: Class<T>, eventHook: EventHook<T>)

Registers an event hook for a specific event class.

Link copied to clipboard

Registers a returnable event hook for a specific event class.

Link copied to clipboard

Shuts down the EventBus, terminating the executor service and clearing the event hook registry. Waits for a specified time for all tasks to complete before forcing shutdown.

Link copied to clipboard
fun <T : Event> unregisterEventHook(eventClass: Class<T>, eventHook: EventHook<T>)

Unregisters an event hook for a specific event class.

Link copied to clipboard

Unregisters a returnable event hook for a specific event class.