maverick.eventbus.EventBus#
- class maverick.eventbus.EventBus(*, strict: bool = False)[source]#
Simple event bus for managing event subscriptions and emissions.
- Parameters:
strict (bool) – If True, exceptions in event handlers will propagate. Otherwise, they will be logged.
Methods
__init__(*[, strict])emit(event, game)Emit an event to all subscribed handlers.
subscribe(event_type, handler, *[, ...])Subscribe to an event type with a handler.
unsubscribe(token)Unsubscribe a handler using its token.
- subscribe(event_type: GameEventType, handler: EventHandler, *, priority: int = 0, once: bool = False, mask: Callable[[Any], bool] | None = None) str[source]#
Subscribe to an event type with a handler.
- Parameters:
event_type (str) – The type of event to subscribe to.
handler (EventHandler) – The function to call when the event is emitted.
priority (int) – Priority of the handler; higher priority handlers are called first.
once (bool) – If True, the handler will be removed after the first call.
mask (Optional[Callable[[Any], bool]]) – Optional filter function to determine if the handler should be called.