Raxol.Core.Runtime.Plugins.API (Raxol v0.2.0)
View SourcePublic API for Raxol plugins to interact with the core system.
This module provides standardized interfaces for plugins to:
- Register event handlers
- Access runtime services
- Register commands
- Access rendering capabilities
- Modify application state in approved ways
Plugin developers should only use these API functions for interacting with the Raxol system to ensure forward compatibility when the internal system changes.
Summary
Functions
Broadcast an event to all subscribers.
Get the current application configuration.
Log a message from a plugin.
Get the path to the plugin data directory.
Register a command that can be executed from the terminal.
Subscribe to runtime events.
Unregister a previously registered command.
Unsubscribe from runtime events.
Functions
Broadcast an event to all subscribers.
Parameters
event_type
- The type of event to broadcastpayload
- Data to include with the event
Returns
:ok
if broadcast was successful
Get the current application configuration.
Parameters
key
- The configuration key to retrievedefault
- Default value if the key is not found
Returns
The configuration value or default
Log a message from a plugin.
Parameters
plugin_id
- The ID of the pluginlevel
- Log level (:debug, :info, :warn, :error)message
- The message to log
Returns
:ok
Get the path to the plugin data directory.
Parameters
plugin_id
- The ID of the plugin
Returns
String path to the plugin's data directory
Register a command that can be executed from the terminal.
Parameters
command_name
- String name of the commandhandler
- Module that will handle the commandhelp_text
- Description of the command for help documentationoptions
- Additional options for the command
Returns
:ok
if command was registered{:error, reason}
if registration failed
Example
API.register_command("myplugin:hello", MyPlugin.Commands,
"Displays a hello message from myplugin")
Subscribe to runtime events.
Parameters
event_type
- The type of event to subscribe tohandler
- Module that will handle the eventfunction
- Function in the handler module that will be called (default: :handle_event)
Returns
:ok
if successful{:error, reason}
if subscription failed
Example
API.subscribe(:key_press, MyPluginHandlers)
Unregister a previously registered command.
Parameters
command_name
- String name of the command to unregister
Returns
:ok
if command was unregistered{:error, reason}
if unregistration failed
Unsubscribe from runtime events.
Parameters
event_type
- The type of event to unsubscribe fromhandler
- Module to unsubscribe
Returns
:ok
if successful{:error, reason}
if unsubscription failed