View Source DSL: Ash.Notifier.PubSub

A pubsub notifier extension.

pub_sub

A section for configuring how resource actions are published over pubsub

See the PubSub and Notifiers guide for more.

Nested DSLs

Examples

pub_sub do
  module MyEndpoint
  prefix "post"

  publish :destroy, ["foo", :id]
  publish :update, ["bar", :name] event: "name_change"
  publish_all :create, "created"
end

Options

NameTypeDefaultDocs
moduleatomThe module to call broadcast/3 on e.g module.broadcast(topic, event, message).
prefixString.tA prefix for all pubsub messages, e.g users. A message with created would be published as users:created
delimiterString.tA delimiter for building topics. Default is a colon (:)
broadcast_type:notification | :phoenix_broadcast | :broadcast:notificationWhat shape the event payloads will be in. See
nameatomA named pub sub to pass as the first argument to broadcast.

pub_sub.publish

publish action, topic

Configure a given action to publish its results over a given topic.

See the PubSub and Notifiers guides for more.

Examples

publish :create, "created"
publish :assign, "assigned"

Arguments

NameTypeDefaultDocs
actionatomThe name of the action that should be published
topicanyThe topic to publish

Options

NameTypeDefaultDocs
previous_values?booleantrueWhether or not to publish messages with both the new values and the old values for referencing changed attributes
eventString.tThe name of the event to publish. Defaults to the action name
dispatcheratomThe module to use as a dispatcher. If none is set, the pubsub module provided is used.

Introspection

Target: Ash.Notifier.PubSub.Publication

pub_sub.publish_all

publish_all type, topic

Works just like publish, except that it takes a type and publishes all actions of that type

See the PubSub and Notifiers guides for more.

Examples

publish_all :create, "created"

Arguments

NameTypeDefaultDocs
type:create | :update | :destroyPublish on all actions of a given type
topicanyThe topic to publish

Options

NameTypeDefaultDocs
actionatomThe name of the action that should be published
previous_values?booleantrueWhether or not to publish messages with both the new values and the old values for referencing changed attributes
eventString.tThe name of the event to publish. Defaults to the action name
dispatcheratomThe module to use as a dispatcher. If none is set, the pubsub module provided is used.

Introspection

Target: Ash.Notifier.PubSub.Publication