Raxol.Core.Events.EventManager (Raxol v2.0.1)
View SourceEvent management system that wraps :telemetry for backward compatibility.
This module provides a compatibility layer while migrating from a custom event system to the standard :telemetry library. New code should use :telemetry directly.
Migration Status
This module now delegates to :telemetry internally. The GenServer functionality is maintained for backward compatibility but will be deprecated in a future version.
Summary
Functions
Returns a specification to start this module under a supervisor.
Cleans up the event manager and all resources.
Clears all registered handlers.
Dispatches an event using :telemetry.
Gets all registered handlers. Returns a list of handler entries.
Initializes the event manager state.
Notifies all registered handlers of an event.
Registers a handler for specific event types.
Subscribes to event streams with optional filtering.
Unregisters a handler for specific event types.
Unsubscribes from event streams.
Types
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec cleanup() :: :ok
Cleans up the event manager and all resources.
@spec clear_handlers() :: :ok
Clears all registered handlers.
@spec dispatch( {event_type(), event_data()} | {event_type(), term(), term()} | event_type() ) :: :ok
Dispatches an event using :telemetry.
This method now delegates to telemetry for event dispatching while maintaining backward compatibility with the old API.
@spec get_handlers() :: list()
Gets all registered handlers. Returns a list of handler entries.
@spec init() :: :ok
Initializes the event manager state.
@spec notify(GenServer.server(), event_type(), event_data()) :: :ok
Notifies all registered handlers of an event.
@spec register_handler( event_type() | [event_type()], pid() | module(), handler_fun() ) :: :ok
Registers a handler for specific event types.
Examples
register_handler(:keyboard, MyModule, :handle_keyboard)
register_handler([:mouse, :touch], self(), :handle_input)
@spec subscribe([event_type()], filter_opts()) :: {:ok, subscription_ref()} | {:error, term()}
Subscribes to event streams with optional filtering.
Examples
{:ok, ref} = subscribe([:keyboard, :mouse])
{:ok, ref} = subscribe([:focus], filter: [component_id: "main"])
@spec unregister_handler( event_type() | [event_type()], pid() | module(), handler_fun() ) :: :ok
Unregisters a handler for specific event types.
@spec unsubscribe(subscription_ref()) :: :ok
Unsubscribes from event streams.