# `AshBackendDrivenOptimisticUi.Registry`
[🔗](https://github.com/Undeadlol1/ash_backend_driven_optimistic_ui/blob/v0.1.0/lib/ash_backend_driven_optimistic_ui/registry.ex#L1)

Every rule of the host app in one payload, with a version.

`rules/0` reads the `:ash_domains` of the app named by
`config :ash_backend_driven_optimistic_ui, otp_app: :my_app` and caches the result in `:persistent_term`; `rules/1` builds from an explicit domain list,
uncached. The payload is `%{"version" => hash, "rules" => rules}` where
`hash` is the first 16 hex characters of the SHA-256 of the rules.

Each rule is `AshBackendDrivenOptimisticUi.Rules`' `%{"effects" => [...]}` plus
`"reactions"`: every `on` of any resource that answers an event the rule
pushes, following pushes made by reactions in turn, in discovery order:

    %{"on" => "xp_awarded", "type" => "wallet", "effects" => [effect]}

A reaction runs once per `{event, type}` per rule, so cycles end.

# `app_domains`

```elixir
@spec app_domains() :: [module()]
```

The `:ash_domains` of the host app named by the `:otp_app` setting.

# `rule_resources`

```elixir
@spec rule_resources([module()]) :: [module()]
```

Every resource of `domains` that declares rules or reactions.

# `rules`

```elixir
@spec rules() :: %{required(String.t()) =&gt; term()}
```

The payload for the app's registered domains, built once per VM.

# `rules`

```elixir
@spec rules([module()]) :: %{required(String.t()) =&gt; term()}
```

The payload for `domains`, uncached.

# `version`

```elixir
@spec version() :: String.t()
```

Just the hash of `rules/0`.

---

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