# `Dstar.Page.Assigns`
[🔗](https://github.com/ricotrevisan/dstar/blob/v0.3.3/lib/dstar/page/assigns.ex#L2)

Assign helpers that work in both halves of a Dstar page module.

`use Dstar.Page` imports these instead of `Phoenix.Component`'s assign
family, so one set of names works everywhere:

- On a `%Plug.Conn{}` (in `mount/2`, `authorize/2`, `handle_event/3`,
  `handle_connect/2`, `handle_info/2`) they behave like `Plug.Conn.assign/3`.
- On anything else (sockets, assigns maps inside function components)
  they delegate to `Phoenix.Component`.

# `assign`

Assigns one key/value or many key/values.

    conn |> assign(:count, 1)
    conn |> assign(count: 1, name: "rico")

Keys must be atoms when assigning to a `%Plug.Conn{}`, matching `Plug.Conn.assign/3` semantics.

# `assign`

# `assign_new`

Assigns a value computed by `fun` only when `key` is absent.
`fun` may take zero arguments or the current assigns.

# `update`

Updates an existing assign with `fun`. Raises `KeyError` if absent.

---

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