Raxol.Plugins.EventHandler (Raxol v0.5.0)
View SourceHandles dispatching various events (input, resize, mouse, etc.) to plugins.
Provides a generic mechanism to iterate through enabled plugins and invoke
specific callback functions defined by the Raxol.Plugins.Plugin
behaviour.
Updates the plugin manager state based on the results returned by the plugins.
Summary
Functions
Dispatches an "input" event to all enabled plugins implementing handle_input/2
.
Dispatches a key event to enabled plugins implementing handle_input/2
.
Returns {:ok, updated_manager, :propagate | :halt} or {:error, reason}.
Dispatches a mouse event to all enabled plugins implementing handle_mouse/3
.
Returns {:ok, updated_manager, :propagate | :halt} or {:error, reason}.
Dispatches an "output" event to all enabled plugins implementing handle_output/2
.
Accumulates transformed output.
Dispatches a "resize" event to all enabled plugins implementing handle_resize/3
.
Types
@type accumulator() :: any()
@type callback_name() :: atom()
@type event() :: map()
@type event_args() :: [any()]
@type handler_payload() :: accumulator() | {:error, term()}
@type handler_result() :: {:cont | :halt, handler_payload()}
@type manager() :: Raxol.Plugins.Manager.Core.t()
@type plugin() :: map()
@type propagation() :: :propagate | :halt
Functions
@spec handle_input(Raxol.Plugins.Manager.Core.t(), binary()) :: result()
Dispatches an "input" event to all enabled plugins implementing handle_input/2
.
@spec handle_key_event(Raxol.Plugins.Manager.Core.t(), map()) :: {:ok, Raxol.Plugins.Manager.Core.t(), propagation()} | {:error, term()}
Dispatches a key event to enabled plugins implementing handle_input/2
.
Returns {:ok, updated_manager, :propagate | :halt} or {:error, reason}.
@spec handle_mouse_event(Raxol.Plugins.Manager.Core.t(), map(), map()) :: {:ok, Raxol.Plugins.Manager.Core.t(), propagation()} | {:error, term()}
Dispatches a mouse event to all enabled plugins implementing handle_mouse/3
.
Returns {:ok, updated_manager, :propagate | :halt} or {:error, reason}.
@spec handle_output(Raxol.Plugins.Manager.Core.t(), binary()) :: {:ok, Raxol.Plugins.Manager.Core.t(), binary()} | {:error, term()}
Dispatches an "output" event to all enabled plugins implementing handle_output/2
.
Accumulates transformed output.
@spec handle_resize(Raxol.Plugins.Manager.Core.t(), integer(), integer()) :: result()
Dispatches a "resize" event to all enabled plugins implementing handle_resize/3
.