# `Ash.Notifier`
[🔗](https://github.com/ash-project/ash/blob/v3.23.1/lib/ash/notifier/notifier.ex#L5)

A notifier is an extension that receives various events

# `load`
*optional* 

```elixir
@callback load(Ash.Resource.t(), Ash.Resource.Actions.action()) ::
  atom() | [atom()] | Keyword.t()
```

A load statement to be applied before this notifier receives the notification.

The loaded fields are merged onto `notification.data` before `notify/1` is called.
If multiple notifiers request the same fields with the same arguments, the
calculation dependency resolver ensures they are only loaded once.

The return value can be anything accepted by `Ash.Query.load/2`, including
`%Ash.Query.Calculation{}` structs for multi-level dependency resolution
(e.g. a PubSub notifier building one inner load per publication).

# `notify`

```elixir
@callback notify(Ash.Notifier.Notification.t()) :: any()
```

# `requires_original_data?`

```elixir
@callback requires_original_data?(Ash.Resource.t(), Ash.Resource.Actions.action()) ::
  boolean()
```

# `extract_notifier_data`

```elixir
@spec extract_notifier_data(
  Ash.Resource.record(),
  [module()],
  Ash.Resource.t(),
  Ash.Resource.Actions.action()
) :: {map(), map()}
```

Extracts pre-loaded notifier dependency data from a record's calculations
and builds the `notifier_data` map used by `enrich_notification/3`.

Returns `{notifier_statements, notifier_data}` where `notifier_data` maps
each notifier to `{statement, extra}`.

# `notifier_calculation_query`

```elixir
@spec notifier_calculation_query(
  Ash.Resource.t(),
  Ash.Resource.Actions.action(),
  map()
) ::
  Ash.Query.t() | nil
```

Builds a query with `NotifierDependencies` calculations for all notifiers
that implement `load/2` with non-empty load statements.

This is meant to be merged into the load that already happens in the action
pipeline, so that notifier dependencies are loaded in bulk (once per batch)
rather than per-notification at dispatch time.

# `notify`

```elixir
@spec notify([Ash.Notifier.Notification.t()] | Ash.Notifier.Notification.t()) :: [
  Ash.Notifier.Notification.t()
]
```

Sends any notifications that can be sent, and returns the rest.

A notification can only be sent if you are not currently in a transaction
for the resource in question.

---

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