Hook#
- class brainstate.Hook(callback, priority=0, name=None, enabled=True)[source]#
Base hook class for all hook types.
A hook encapsulates a callback function along with metadata about its execution priority, name, and enabled state.
- callback#
The callable to invoke when the hook executes
- priority#
Execution priority (higher = executes earlier)
- name#
Optional name for the hook (for debugging/logging)
- enabled#
Whether the hook is currently enabled
- hook_id#
Unique identifier for the hook
- execute(context)[source]#
Execute the hook callback with the given context.
- Parameters:
context (
HookContext) – The hook context to pass to the callback- Return type:
- Raises:
HookExecutionError – If the callback raises an exception