A2UI.SurfaceManager (A2UI v0.3.0)

Copy Markdown View Source

Pure functional state manager for A2UI surfaces.

Manages a %{surface_id => %Surface{}} map by applying protocol messages. No GenServer — surfaces live in LiveView assigns.

Summary

Functions

Applies a protocol message to the surfaces map.

Creates an empty surfaces map.

Types

surfaces()

@type surfaces() :: %{required(String.t()) => A2UI.Surface.t()}

Functions

apply_message(surfaces, msg)

@spec apply_message(surfaces(), struct()) :: {:ok, surfaces()} | {:error, atom()}

Applies a protocol message to the surfaces map.

Returns {:ok, updated_surfaces} or {:error, reason}.

new()

@spec new() :: surfaces()

Creates an empty surfaces map.