# `PhoenixReplay.Recording.State`
[🔗](https://github.com/elixir-vibe/phoenix_replay/blob/v0.6.2/lib/phoenix_replay/recording/state.ex#L1)

Client state on a recording's timeline.

`:state` events are stored as the batches the browser sent; see
`PhoenixReplay.Capture.State`. `spread/1` turns each into one `:state`
event per entry, `%{key: String.t(), changes: map}`, at its own offset
from the session's start: the batch arrived at its event's `at`, and its
entries span the `span` milliseconds before that. The player then steps
through them like any other event, and `PhoenixReplay.Recording.Timeline`
merges each entry's changes into the `:phoenix_replay_state`
assign, `%{key => merged changes}`, which a view's `replay_render/1`
reads. See `assign/0`.

The values of form controls the browser records on its own are kept
under `inputs_key/0`, `%{selector => %{name => value}}`; the replay
frame puts them back into the replayed page after each render.

# `apply`

```elixir
@spec apply(map(), PhoenixReplay.Recording.Event.t()) :: map()
```

Merges a `:state` event's changes into the state replayed so far.

# `assign`

```elixir
@spec assign() :: atom()
```

The reserved assign the replayed state is merged into: a map of each
key's merged changes, with string keys, empty before any state.

# `inputs`

```elixir
@spec inputs(map()) :: map()
```

The form control values in replayed `state`, as `inputs_key/0` describes.

# `inputs_key`

```elixir
@spec inputs_key() :: String.t()
```

The key form control values are recorded under: a map of each control's
selector to `%{name => value}`, where the value is its text, whether it
is checked, or the options chosen.

# `spread`

```elixir
@spec spread(PhoenixReplay.Recording.t()) :: PhoenixReplay.Recording.t()
```

Places each entry of the recording's `:state` batches on its timeline as
a `:state` event of its own. The other events keep their order; an entry
goes before the first of them that happened after it. Recordings already
spread are returned as they are.

---

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