Action and filter hook system for Voile plugins.
Uses :persistent_term for hook storage, providing zero-cost concurrent
reads. Registration and unregistration go through a GenServer to serialize
writes to :persistent_term.
Action Hooks
Plugins react to events. Return values are ignored.
Voile.Hooks.run_action(:visitor_checked_in, %{visitor_id: id})Filter Hooks
Plugins transform data. Each handler receives the accumulated value and must return a possibly-modified version.
widgets = Voile.Hooks.run_filter(:dashboard_widgets, base_widgets)Registering Handlers
Voile.Hooks.register(:dashboard_widgets, &MyPlugin.add_widget/1,
owner: MyPlugin, priority: 30)Unregistering (on plugin deactivation)
Voile.Hooks.unregister_all(MyPlugin)
Summary
Functions
Returns a specification to start this module under a supervisor.
Get all handlers for a specific hook (for debugging/inspection).
List all registered hook names.
Register a handler for a named hook.
Run action hooks. All handlers are called with payload.
Return values are ignored. Errors in one handler do NOT stop others.
Run filter hooks. Handlers are called in priority order, each receiving the return value of the previous. The final accumulated value is returned.
Unregister ALL hooks registered by a specific plugin module.
Types
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Get all handlers for a specific hook (for debugging/inspection).
List all registered hook names.
Register a handler for a named hook.
Options:
owner:(module) — used to unregister all hooks for a plugin at oncepriority:(integer) — lower numbers run first, default 50
Run action hooks. All handlers are called with payload.
Return values are ignored. Errors in one handler do NOT stop others.
Run filter hooks. Handlers are called in priority order, each receiving the return value of the previous. The final accumulated value is returned.
If a handler raises, the error is logged and the previous value is kept.
Unregister ALL hooks registered by a specific plugin module.