EventBus

public class EventBus

Properties

Link copied to clipboard
public final static EventBus INSTANCE
Link copied to clipboard
private final Boolean isDebug
Link copied to clipboard
private final Boolean isInitialized

Functions

Link copied to clipboard
public final static Unit initialize(String packageNames, Integer threadPoolSize, Boolean isDebug)
public final static Unit initialize(String packageNames, Integer threadPoolSize)
public final static Unit initialize(String packageNames)

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
public final Boolean isDebug()
Link copied to clipboard
public final Boolean isInitialized()
Link copied to clipboard
public final static T postAsync<T extends Event>(T event)

Posts an event asynchronously.

Link copied to clipboard
public final static T postDelayed<T extends Event>(T event, Long delay, TimeUnit timeUnit, EventProcessingType processingType)

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

Link copied to clipboard
public final static T postFullSync<T extends Event>(T event)

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

Link copied to clipboard
public final static T postHandlerAsync<T extends Event>(T event)

Posts an event synchronously.

Link copied to clipboard
public final static R postReturnable<T extends ReturnableEvent<R>, R extends Any>(T event, EventProcessingType processingType)

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

Link copied to clipboard
public final static T postWithCallback<T extends Event>(T event, Function1<T, Unit> callback, Long delay, EventProcessingType processingType)

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

Link copied to clipboard
public final static T postWithTimeout<T extends Event>(T event, Long timeout, TimeUnit timeUnit, EventProcessingType processingType)

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

Link copied to clipboard
public final static T processEvent<T extends Event>(T event, EventProcessingType processingType)

Processes an event based on the specified processing type.

Link copied to clipboard
public final static Unit registerEventHook<T extends Event>(Class<T> eventClass, EventHook<T> eventHook)

Registers an event hook for a specific event class.

Link copied to clipboard
public final static Unit registerReturnableEventHook<T extends ReturnableEvent<R>, R extends Any>(Class<T> eventClass, ReturnableEventHook<T, R> eventHook)

Registers a returnable event hook for a specific event class.

Link copied to clipboard
public final static Unit shutdown()

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.