# `Macaw.Live.Keyed`
[🔗](https://github.com/dcoai/macaw_live/blob/v0.1.0/lib/macaw/live/keyed.ex#L1)

A keyed render (spec/01 §3.3): a component's render answered as keyed parts, which the
runtime places by key, so a change sends only the rows whose markup changed. The
runtime knows it by its shape alone, never by its module (spec/00 §1, it is generic):
a struct implementing `Phoenix.HTML.Safe` with

  * `head`, `gap_before`, `gap_after` and `tail`, iodata, placed as they are;
  * `rows`, `[{key, version, markup}]` in the order drawn, each key unique within the
    render, `markup` iodata, `version` what the markup reads beyond the render's
    `scope` (`nil` for markup never to be reused);
  * `scope` (optional), what every row's markup reads besides.

Flattened (`Phoenix.HTML.Safe.to_iodata/1`), it is the head, the gap before, each row's
markup in order, the gap after and the tail. macaw's built-in table answers one
(`Rows`, macaw#434).

# `held`

```elixir
@type held() :: %{required({term(), term()}) =&gt; binary()}
```

The rows a runtime holds for a keyed render, as macaw_component's `held` assign takes
them (its spec/02 §1.2): each row's markup, one binary, by the render's scope and the
row's version.

# `t`

```elixir
@type t() :: %{
  :__struct__ =&gt; module(),
  :head =&gt; iodata(),
  :gap_before =&gt; iodata(),
  :rows =&gt; [{term(), term(), iodata()}],
  :gap_after =&gt; iodata(),
  :tail =&gt; iodata(),
  optional(atom()) =&gt; term()
}
```

A keyed render: a struct of the shape above.

# `bytes`

```elixir
@spec bytes(t()) :: non_neg_integer()
```

The bytes of markup the keyed render flattens to.

# `kept`

```elixir
@spec kept(held() | nil, term()) :: held() | nil
```

The rows a page keeps beside a cell after placing `keyed` (spec/01 §3.4), from those it
kept before: each row with a version under the render's `scope`, its markup the binary
written. A row `kept` already holds costs a lookup and changes nothing, so a render
whose every row was held (a sort, an equal refetch) answers `kept` itself; new rows are
added; past four times the rows placed (at least 1,000 entries) it starts again from
the rows just placed. `nil` for a render with no scope, or something not keyed.

# `keyed?`
*macro* 

Whether `term` is a keyed render, by its shape: usable in a guard.

# `written`

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

The keyed render with each part, and each row's markup, written out to a binary of its own.

---

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