All live surfaces of a session, keyed by surface id.
Lifecycle operations return the updated group and the effects a host
may react to ({:surface_created, id}, {:surface_deleted, id}).
Adding an existing id and deleting an unknown id are no-ops with no
effects, as in the reference.
iex> alias A2UICore.State.{Surface, SurfaceGroup}
iex> {group, [{:surface_created, "main"}]} =
...> SurfaceGroup.new() |> SurfaceGroup.add(Surface.new("main"))
iex> SurfaceGroup.ids(group)
["main"]
iex> {group, [{:surface_deleted, "main"}]} = SurfaceGroup.delete(group, "main")
iex> SurfaceGroup.ids(group)
[]
Summary
Functions
Adds a surface; an id already present is left untouched.
Deletes and disposes a surface; an unknown id is ignored.
Deletes every surface.
The surface with id, or nil.
Whether a surface with id exists.
The surface ids, sorted.
An empty group.
The surfaces, sorted by id.
Replaces an existing surface's state (after a data or component update). An unknown id is ignored.
Types
@type t() :: %A2UICore.State.SurfaceGroup{ surfaces: %{optional(String.t()) => A2UICore.State.Surface.t()} }
Functions
@spec add(t(), A2UICore.State.Surface.t()) :: {t(), [effect()]}
Adds a surface; an id already present is left untouched.
Deletes and disposes a surface; an unknown id is ignored.
Deletes every surface.
@spec get(t(), String.t()) :: A2UICore.State.Surface.t() | nil
The surface with id, or nil.
Whether a surface with id exists.
The surface ids, sorted.
@spec new() :: t()
An empty group.
@spec to_list(t()) :: [A2UICore.State.Surface.t()]
The surfaces, sorted by id.
@spec update(t(), A2UICore.State.Surface.t()) :: t()
Replaces an existing surface's state (after a data or component update). An unknown id is ignored.