# `DoubleDown.Dispatch.HandlerMeta.Stateful`
[🔗](https://github.com/mccraigmccraig/double_down/blob/main/lib/double_down/dispatch/handler_meta.ex#L46)

Handler meta for a stateful (4/5-arity) function handler.

The `:state` field holds the mutable handler state directly —
for raw `set_stateful_handler` this is user-provided state,
for `Double`-managed handlers it is a `CanonicalHandlerState` struct.

# `t`

```elixir
@type t() :: %DoubleDown.Dispatch.HandlerMeta.Stateful{
  fun: DoubleDown.Dispatch.Types.stateful_fun(),
  state: term()
}
```

# `new`

```elixir
@spec new(DoubleDown.Dispatch.Types.stateful_fun(), term()) :: t()
```

Create a new Stateful handler meta. Validates that `fun` is a 4 or 5-arity function.

# `put_state`

```elixir
@spec put_state(t(), term()) :: t()
```

Replace the state within a Stateful handler meta.

# `update_state`

```elixir
@spec update_state(t(), (term() -&gt; term())) :: t()
```

Update the state within a Stateful handler meta via a function.

---

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