View Source Ash.Notifier.PubSub (ash v2.5.14)
A pubsub notifier extension.
dsl-documentation
DSL Documentation
index
Index
- pub_sub
- publish
- publish_all
docs
Docs
pub_sub
pub_sub
A section for configuring how resource actions are published over pubsub
See the PubSub and Notifiers guide for more.
Examples:
pub_sub do
module MyEndpoint
prefix "post"
broadcast_type :phoenix_broadcast
publish :destroy, ["foo", :id]
publish :update, ["bar", :name] event: "name_change"
publish_all :create, "created"
end
:module(atom/0) - Required. The module to callbroadcast/3on e.g module.broadcast(topic, event, message).:prefix(String.t/0) - A prefix for all pubsub messages, e.gusers. A message withcreatedwould be published asusers:created:broadcast_type- What shape the event payloads will be in.:notificationjust sends the notification,phoenix_broadcastsends a%Phoenix.Socket.Broadcast{}, and:broadcastsends%{topic: <topic>, event: <event>, notification: <notification>}The default value is:notification.:name(atom/0) - A named pub sub to pass as the first argument to broadcast.
If you are using a phoenixEndpointmodule for pubsub then this is unnecessary. If you want to use a custom pub sub started with something like{Phoenix.PubSub, name: MyName}, then you can provideMyNameto here.
publish
publish
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"
:action(atom/0) - Required. The name of the action that should be published:topic- Required. The topic to publish:event(String.t/0) - The name of the event to publish. Defaults to the action name:dispatcher(atom/0) - The module to use as a dispatcher. If none is set, the pubsub module provided is used.
publish_all
publish_all
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":type- Publish on all actions of a given type:action(atom/0) - The name of the action that should be published:topic- Required. The topic to publish:event(String.t/0) - The name of the event to publish. Defaults to the action name:dispatcher(atom/0) - The module to use as a dispatcher. If none is set, the pubsub module provided is used.