Starts an A2UI WebSocket server, embeddable in any OTP supervision tree.
Example
# In your application supervisor:
children = [
{A2UI.Server,
provider: MyApp.DashboardProvider,
port: 4000}
]
Supervisor.start_link(children, strategy: :one_for_one)Options
:provider(required) — module implementingA2UI.SurfaceProvider:provider_opts— map passed toprovider.init/1(default:%{}):port— HTTP port (default:4000):ip— bind address (default:{127, 0, 0, 1})
All other options are forwarded to Bandit.
Push Updates
Use push_data/3 and push_surface/2 to broadcast updates to all
connected clients from external processes (timers, PubSub, GenServer casts):
A2UI.Server.push_data("dashboard", %{"/uptime" => 42},
provider: MyApp.DashboardProvider)
A2UI.Server.push_surface(updated_surface,
provider: MyApp.DashboardProvider)You can also pass registry: directly if you've already resolved it.
Summary
Functions
Sends an arbitrary message to all connected socket processes for the given surface.
Sends an arbitrary message to all connected socket processes for the provider, regardless of surface ID.
Returns a child specification for starting the A2UI server under a supervisor.
Broadcasts a data model update to all connected clients for the given surface.
Broadcasts a full surface update to all connected clients.
Starts the A2UI server linked to the current process.
Functions
Sends an arbitrary message to all connected socket processes for the given surface.
Options
:provider— the provider module (resolves registry automatically):registry— the Registry name directly (use one or the other)
Sends an arbitrary message to all connected socket processes for the provider, regardless of surface ID.
Options
:provider— the provider module (resolves registry automatically):registry— the Registry name directly (use one or the other)
Examples
A2UI.Server.broadcast_all(:tick, provider: MyApp.Provider)
@spec child_spec(keyword()) :: Supervisor.child_spec()
Returns a child specification for starting the A2UI server under a supervisor.
Broadcasts a data model update to all connected clients for the given surface.
Options
:provider— the provider module (resolves registry automatically):registry— the Registry name directly (use one or the other)
Examples
A2UI.Server.push_data("dashboard", %{"/uptime" => 42}, provider: MyApp.Provider)
@spec push_surface( A2UI.Surface.t(), keyword() ) :: :ok
Broadcasts a full surface update to all connected clients.
Options
:provider— the provider module (resolves registry automatically):registry— the Registry name directly (use one or the other)
Examples
A2UI.Server.push_surface(updated_surface, provider: MyApp.Provider)
Starts the A2UI server linked to the current process.
See child_spec/1 for available options.