# `Soundcheck.Check.Warning.AsyncAssignFieldRead`
[🔗](https://github.com/leonqadirie/soundcheck/blob/v0.1.0/lib/soundcheck/check/warning/async_assign_field_read.ex#L1)

## Basics

> #### This check is disabled by default. {: .neutral}
>
> [Learn how to enable it](`e:credo:config_file.html#checks`) via `.credo.exs`.

This check has a base priority of `high` and works with any version of Elixir.

## Explanation

Flags template reads such as `@org.name` of an assign that
`assign_async/3,4` sets. The assign holds a
`Phoenix.LiveView.AsyncResult`, whose only fields are `ok?`,
`loading`, `failed`, and `result`, so any other field raises
`KeyError` on render.

Before:

    assign_async(socket, :org, fn -> {:ok, %{org: fetch_org!(id)}} end)

    <h1>{@org.name}</h1>

After:

    <.async_result :let={org} assign={@org}>
      <:loading>Loading...</:loading>
      <h1>{org.name}</h1>
    </.async_result>

The check reads the module's own writes: a key counts as async when
`assign_async` sets it and every other write is an `update/3` or a
value built with `AsyncResult`. Reads come from the module's
`render/1` template, colocated or inline.

Confidence: high. Tier: syntactic (works without compiling).

## Check-Specific Parameters

Use the following parameters to configure this check:

### `:excluded_paths`

  Paths to skip (atoms, binaries as path segments, or regexes).

*This parameter defaults to* `[~r/\/test\//, "test"]`.

### `:strict`

  Unused.

*This parameter defaults to* `false`.

## General Parameters

Like with all checks, [general params](`e:credo:check_params.html`) can be applied.

Parameters can be configured via the [`.credo.exs` config file](`e:credo:config_file.html`).

---

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