EventBus

open class EventBus

EventBus is a simple implementation of an event bus pattern. It allows components to subscribe to specific events and receive notifications when those events occur. This class provides mechanisms for registering, emitting, and removing event handlers.

Inheritors

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
Link copied to clipboard
fun emit(event: String, data: Any)

Executes all registered event handlers for a given event

Link copied to clipboard
fun on(event: String, handler: (data: Any) -> Unit)

Registers an event handler for a given event

Link copied to clipboard
fun once(event: String, handler: (data: Any) -> Unit)

Registers an event handler for a given event

Link copied to clipboard
fun removeEventListener(event: String, handler: (data: Any) -> Unit? = null): Boolean

Unregisters an event handler for a given event