Dynamically routes events from Vue to Ash actions based on Spark DSL.
This is the core routing engine of Alva. When the frontend calls an event
(e.g. alva.catalog.list_products()), the dispatch/3 function resolves
the event name against the Alva.Registry, looks up the target Ash.Resource
action, executes it, and returns a normalized result.
Event Resolution
Events are resolved either through an :otp_app (host application) or a list of
:domains. The dispatcher also handles:
- File upload consumption via
Phoenix.LiveViewupload entries - Actor and tenant injection from socket assigns
- Pagination options (
:page,:sort) - Dry-run validation for create/update events (
validate_only) - Telemetry instrumentation (
[:alva, :dispatch, :stop])
See Alva.Resource for how events are defined, and Alva.LiveView for how
dispatching is wired into the LiveView lifecycle.
Summary
Functions
Routes a frontend event to the matching Ash action.
Functions
Routes a frontend event to the matching Ash action.
Options
:socket- APhoenix.LiveView.Socketfor upload consumption and auth resolution.:otp_app- The host OTP app for registry lookup.:domains- A list ofAsh.Domainmodules (used when:otp_appis not provided).:actor- The actor for Ash authorization (auto-resolved from socket assigns).:tenant- The tenant for Ash multitenancy (auto-resolved from socket assigns).
Returns %{ok: true, data: payload} on success, or
%{ok: false, error: error_map} on failure.