Raxol.Events.EventServer (Raxol v2.0.1)

View Source

Unified event handler consolidating all event processing capabilities.

Replaces fragmented event handlers with a single, coherent system that handles:

  • Terminal events (input, output, resize)
  • Plugin events (lifecycle, state changes)
  • UI events (interactions, updates)
  • Accessibility events (focus, navigation)
  • Core runtime events (system, performance)

Design Principles

  1. Single Entry Point: All events flow through this unified handler
  2. Event Routing: Intelligent routing based on event type and context
  3. Handler Delegation: Delegates to specialized handlers when needed
  4. Event Tracing: Built-in event tracing for debugging and monitoring
  5. Performance: Optimized event processing with minimal overhead

Event Categories

  • Terminal Events: Input/output, resize, cursor, buffer operations
  • Plugin Events: Installation, activation, lifecycle, errors
  • UI Events: Component interactions, theme changes, accessibility
  • System Events: Performance metrics, error conditions, state changes

Summary

Functions

Returns a specification to start this module under a supervisor.

Handles accessibility events (focus, navigation, etc.).

Handles any event by routing to appropriate specialized handler.

Legacy compatibility methods for existing code.

Handles plugin events (lifecycle, state changes, etc.).

Handles terminal events (input, output, resize, etc.).

Start the unified event handler.

Types

event_data()

@type event_data() :: map()

event_type()

@type event_type() :: :terminal | :plugin | :ui | :accessibility | :system

handler_result()

@type handler_result() :: {:ok, any()} | {:error, term()}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

handle_accessibility_event(server \\ __MODULE__, event_name, event_data)

@spec handle_accessibility_event(GenServer.server(), atom(), any()) ::
  handler_result()

Handles accessibility events (focus, navigation, etc.).

handle_event(server \\ __MODULE__, event_type, event_data)

@spec handle_event(GenServer.server(), event_type(), event_data()) :: handler_result()

Handles any event by routing to appropriate specialized handler.

handle_input(manager, input)

Legacy compatibility methods for existing code.

handle_manager_cast(msg, state)

Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_cast/2.

handle_manager_info(msg, state)

Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_info/2.

handle_output(manager, output)

handle_plugin_event(server \\ __MODULE__, event_name, event_data)

@spec handle_plugin_event(GenServer.server(), atom(), any()) :: handler_result()

Handles plugin events (lifecycle, state changes, etc.).

handle_resize(manager, width, height)

handle_terminal_event(server \\ __MODULE__, event_name, event_data)

@spec handle_terminal_event(GenServer.server(), atom(), any()) :: handler_result()

Handles terminal events (input, output, resize, etc.).

init_manager(opts)

Start the unified event handler.

start_link(init_opts \\ [])