# `DoubleDown.Contract.Dispatch.Defer`
[🔗](https://github.com/mccraigmccraig/double_down/blob/main/lib/double_down/contract/dispatch/defer.ex#L1)

A deferred execution marker.

When a handler or test double returns `%DoubleDown.Contract.Dispatch.Defer{fun: fun}`,
the dispatch system releases the NimbleOwnership lock before calling
`fun.()`. This avoids deadlocks when the deferred function makes
further dispatched calls (e.g. `transact` calling `insert` inside
its body).

**For users of the Double API**, prefer `DoubleDown.Double.defer/1`
over constructing this struct directly.

Used internally by `Repo.Stub`, `Repo.OpenInMemory`, and
`DoubleDown.Double`'s canonical handler.

# `t`

```elixir
@type t() :: %DoubleDown.Contract.Dispatch.Defer{fun: (-&gt; term())}
```

# `new`

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

Create a new Defer marker. Validates that `fun` is a 0-arity function.

---

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