Raxol.Core.Runtime.Plugins.API (Raxol v0.3.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.
Subscribe to runtime events.
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
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)
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