# `A2UICore.State.SurfaceGroup`
[🔗](https://github.com/a2ui-elixir/a2ui/blob/v0.1.1/umbrella/apps/a2ui_core/lib/a2ui_core/state/surface_group.ex#L1)

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)
    []

# `effect`
*since 0.1.0* 

```elixir
@type effect() :: {:surface_created, String.t()} | {:surface_deleted, String.t()}
```

# `t`
*since 0.1.0* 

```elixir
@type t() :: %A2UICore.State.SurfaceGroup{
  surfaces: %{optional(String.t()) =&gt; A2UICore.State.Surface.t()}
}
```

# `add`
*since 0.1.0* 

```elixir
@spec add(t(), A2UICore.State.Surface.t()) :: {t(), [effect()]}
```

Adds a surface; an id already present is left untouched.

# `delete`
*since 0.1.0* 

```elixir
@spec delete(t(), String.t()) :: {t(), [effect()]}
```

Deletes and disposes a surface; an unknown id is ignored.

# `dispose`
*since 0.1.0* 

```elixir
@spec dispose(t()) :: {t(), [effect()]}
```

Deletes every surface.

# `get`
*since 0.1.0* 

```elixir
@spec get(t(), String.t()) :: A2UICore.State.Surface.t() | nil
```

The surface with `id`, or `nil`.

# `has?`
*since 0.1.0* 

```elixir
@spec has?(t(), String.t()) :: boolean()
```

Whether a surface with `id` exists.

# `ids`
*since 0.1.0* 

```elixir
@spec ids(t()) :: [String.t()]
```

The surface ids, sorted.

# `new`
*since 0.1.0* 

```elixir
@spec new() :: t()
```

An empty group.

# `to_list`
*since 0.1.0* 

```elixir
@spec to_list(t()) :: [A2UICore.State.Surface.t()]
```

The surfaces, sorted by id.

# `update`
*since 0.1.0* 

```elixir
@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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
