Raxol.Core.Runtime.Events.Handlers (Raxol v0.3.0)
View SourceManages event handlers registration and execution in the Raxol system.
This module is responsible for:
- Registering event handlers for specific event types
- Executing handlers when events occur
- Managing the priority and order of handlers
Summary
Functions
Executes all registered handlers for the given event.
Registers a new event handler for the specified event types.
Unregisters an event handler.
Functions
Executes all registered handlers for the given event.
Handlers are executed in priority order (lowest to highest). Each handler can transform the event for the next handler.
Parameters
event
: The event to handlestate
: The current application state
Returns
{:ok, updated_event, updated_state}
if all handlers executed successfully,
{:error, reason, state}
if a handler failed.
Registers a new event handler for the specified event types.
Parameters
handler_id
: Unique identifier for the handlerevent_types
: List of event types the handler should receivehandler_fun
: Function to call when an event occursoptions
: Additional options for handler registration:priority
- Handler priority (default: 100, lower numbers run first):filter
- Optional filter function to determine if events should be handled
Returns
{:ok, handler_id}
if registration succeeded,
{:error, reason}
otherwise.
Unregisters an event handler.
Parameters
handler_id
: ID of the handler to remove
Returns
:ok
if the handler was removed,
{:error, :not_found}
if the handler wasn't registered.