# `StarView.Signals`
[🔗](https://github.com/Neophen/star_view/blob/v0.7.0/lib/star_view/signals.ex#L1)

Datastar signal reading and `datastar-patch-signals` helpers.

# `fetch`

```elixir
@spec fetch(Plug.Conn.t(), keyword()) ::
  {:ok, map(), Plug.Conn.t()} | {:error, term(), Plug.Conn.t()}
```

Fetches an object signal document and returns Plug's updated connection.

Raw bodies and the `datastar` query JSON are limited to 1,000,000 bytes by
default, configurable with `:max_bytes`. Already-parsed body params rely on
`Plug.Parsers`'s configured length limit. Always thread the returned conn.

# `format_patch`

```elixir
@spec format_patch(map(), keyword()) :: String.t()
```

Formats a signal patch without writing to a connection.

# `format_patch_raw`

```elixir
@spec format_patch_raw(String.t(), keyword()) :: String.t()
```

Formats a raw JSON signal patch without writing to a connection.

# `format_remove`

```elixir
@spec format_remove(String.t() | [String.t()], keyword()) :: String.t()
```

Formats a signal removal without writing to a connection.

# `patch`

```elixir
@spec patch(Plug.Conn.t(), map(), keyword()) :: Plug.Conn.t()
```

Sends a signal patch from a map.

# `patch_raw`

```elixir
@spec patch_raw(Plug.Conn.t(), String.t(), keyword()) :: Plug.Conn.t()
```

Sends a signal patch from a JSON string.

# `read`

```elixir
@spec read(Plug.Conn.t()) :: {:ok, map()} | {:error, term()}
```

Reads Datastar signals from a Plug connection.

`GET` and `DELETE` requests read the `datastar` query parameter. Other
methods read JSON from the request body unless a parser has already populated
`conn.body_params`. For raw bodies, prefer `fetch/2` so the updated conn
reaches subsequent plugs; this compatibility API returns only the result.

# `read!`

```elixir
@spec read!(Plug.Conn.t()) :: map()
```

Reads Datastar signals and raises on errors.

# `remove_signals`

```elixir
@spec remove_signals(Plug.Conn.t(), String.t() | [String.t()], keyword()) ::
  Plug.Conn.t()
```

Removes one or more signals by setting dot-notated paths to `null`.

# `send_error`

```elixir
@spec send_error(Plug.Conn.t(), term()) :: Plug.Conn.t()
```

Sends a plain HTTP 400 or 413 response for a signal input error before SSE starts.
