Ash.Notifier behaviour (ash v3.17.1)

Copy Markdown View Source

A notifier is an extension that receives various events

Summary

Callbacks

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

Functions

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

Callbacks

load(t, action)

(optional)
@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(t)

@callback notify(Ash.Notifier.Notification.t()) :: :ok

requires_original_data?(t, action)

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

Functions

notify(resource_notifications)

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.