documentation/dsls/DSL:-Ash.Notifier.PubSub.cheatmd

<!--
This file was generated by Spark. Do not edit it by hand.
-->
# DSL: Ash.Notifier.PubSub

A pubsub notifier extension.


## pub_sub
A section for configuring how resource actions are published over pubsub

See the [PubSub](/documentation/topics/pub_sub.md) and [Notifiers](/documentation/topics/notifiers.md) guide for more.


### Nested DSLs
 * [publish](#pub_sub-publish)
 * [publish_all](#pub_sub-publish_all)


### 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

```




### Options

<table>
  <thead>
    <tr>
      <th>Name</th>
      <th>Type</th>
      <th>Default</th>
      <th colspan=2>Docs</th>
    </tr>
  </thead>
  <tbody>
    <tr>
  <td style="text-align: left">
    <a id="pub_sub-module" href="#pub_sub-module">
      <span style="font-family: Inconsolata, Menlo, Courier, monospace;">
        module
      </span>
    </a>
      <sup style="color: red">*</sup>

  </td>
  <td style="text-align: left">
    <code class="inline">atom</code>
  </td>
  <td style="text-align: left">
    
  </td>
  <td style="text-align: left" colspan=2>
    The module to call `broadcast/3` on e.g module.broadcast(topic, event, message).
  </td>
</tr>

<tr>
  <td style="text-align: left">
    <a id="pub_sub-prefix" href="#pub_sub-prefix">
      <span style="font-family: Inconsolata, Menlo, Courier, monospace;">
        prefix
      </span>
    </a>
      
  </td>
  <td style="text-align: left">
    <code class="inline">String.t</code>
  </td>
  <td style="text-align: left">
    
  </td>
  <td style="text-align: left" colspan=2>
    A prefix for all pubsub messages, e.g `users`. A message with `created` would be published as `users:created`
  </td>
</tr>

<tr>
  <td style="text-align: left">
    <a id="pub_sub-broadcast_type" href="#pub_sub-broadcast_type">
      <span style="font-family: Inconsolata, Menlo, Courier, monospace;">
        broadcast_type
      </span>
    </a>
      
  </td>
  <td style="text-align: left">
    <code class="inline">:notification | :phoenix_broadcast | :broadcast</code>
  </td>
  <td style="text-align: left">
    <code class="inline">:notification</code>
  </td>
  <td style="text-align: left" colspan=2>
    What shape the event payloads will be in. See

  </td>
</tr>

<tr>
  <td style="text-align: left">
    <a id="pub_sub-name" href="#pub_sub-name">
      <span style="font-family: Inconsolata, Menlo, Courier, monospace;">
        name
      </span>
    </a>
      
  </td>
  <td style="text-align: left">
    <code class="inline">atom</code>
  </td>
  <td style="text-align: left">
    
  </td>
  <td style="text-align: left" colspan=2>
    A named pub sub to pass as the first argument to broadcast.
  </td>
</tr>

  </tbody>
</table>



## pub_sub.publish
```elixir
publish action, topic
```


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

See the [PubSub](/documentation/topics/pub_sub.md) and [Notifiers](/documentation/topics/notifiers.md) guides for more.




### Examples
```
publish :create, "created"
```

```
publish :assign, "assigned"

```



### Arguments

<table>
  <thead>
    <tr>
      <th>Name</th>
      <th>Type</th>
      <th>Default</th>
      <th colspan=2>Docs</th>
    </tr>
  </thead>
  <tbody>
    <tr>
  <td style="text-align: left">
    <a id="pub_sub-publish-action" href="#pub_sub-publish-action">
      <span style="font-family: Inconsolata, Menlo, Courier, monospace;">
        action
      </span>
    </a>
      <sup style="color: red">*</sup>

  </td>
  <td style="text-align: left">
    <code class="inline">atom</code>
  </td>
  <td style="text-align: left">
    
  </td>
  <td style="text-align: left" colspan=2>
    The name of the action that should be published
  </td>
</tr>

<tr>
  <td style="text-align: left">
    <a id="pub_sub-publish-topic" href="#pub_sub-publish-topic">
      <span style="font-family: Inconsolata, Menlo, Courier, monospace;">
        topic
      </span>
    </a>
      <sup style="color: red">*</sup>

  </td>
  <td style="text-align: left">
    <code class="inline">`any`</code>
  </td>
  <td style="text-align: left">
    
  </td>
  <td style="text-align: left" colspan=2>
    The topic to publish
  </td>
</tr>

  </tbody>
</table>
### Options

<table>
  <thead>
    <tr>
      <th>Name</th>
      <th>Type</th>
      <th>Default</th>
      <th colspan=2>Docs</th>
    </tr>
  </thead>
  <tbody>
    <tr>
  <td style="text-align: left">
    <a id="pub_sub-publish-event" href="#pub_sub-publish-event">
      <span style="font-family: Inconsolata, Menlo, Courier, monospace;">
        event
      </span>
    </a>
      
  </td>
  <td style="text-align: left">
    <code class="inline">String.t</code>
  </td>
  <td style="text-align: left">
    
  </td>
  <td style="text-align: left" colspan=2>
    The name of the event to publish. Defaults to the action name
  </td>
</tr>

<tr>
  <td style="text-align: left">
    <a id="pub_sub-publish-dispatcher" href="#pub_sub-publish-dispatcher">
      <span style="font-family: Inconsolata, Menlo, Courier, monospace;">
        dispatcher
      </span>
    </a>
      
  </td>
  <td style="text-align: left">
    <code class="inline">atom</code>
  </td>
  <td style="text-align: left">
    
  </td>
  <td style="text-align: left" colspan=2>
    The module to use as a dispatcher. If none is set, the pubsub module provided is used.
  </td>
</tr>

  </tbody>
</table>





### Introspection

Target: `Ash.Notifier.PubSub.Publication`

## pub_sub.publish_all
```elixir
publish_all type, topic
```


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

See the [PubSub](/documentation/topics/pub_sub.md) and [Notifiers](/documentation/topics/notifiers.md) guides for more.




### Examples
```
publish_all :create, "created"
```



### Arguments

<table>
  <thead>
    <tr>
      <th>Name</th>
      <th>Type</th>
      <th>Default</th>
      <th colspan=2>Docs</th>
    </tr>
  </thead>
  <tbody>
    <tr>
  <td style="text-align: left">
    <a id="pub_sub-publish_all-type" href="#pub_sub-publish_all-type">
      <span style="font-family: Inconsolata, Menlo, Courier, monospace;">
        type
      </span>
    </a>
      
  </td>
  <td style="text-align: left">
    <code class="inline">:create | :update | :destroy</code>
  </td>
  <td style="text-align: left">
    
  </td>
  <td style="text-align: left" colspan=2>
    Publish on all actions of a given type
  </td>
</tr>

<tr>
  <td style="text-align: left">
    <a id="pub_sub-publish_all-topic" href="#pub_sub-publish_all-topic">
      <span style="font-family: Inconsolata, Menlo, Courier, monospace;">
        topic
      </span>
    </a>
      <sup style="color: red">*</sup>

  </td>
  <td style="text-align: left">
    <code class="inline">`any`</code>
  </td>
  <td style="text-align: left">
    
  </td>
  <td style="text-align: left" colspan=2>
    The topic to publish
  </td>
</tr>

  </tbody>
</table>
### Options

<table>
  <thead>
    <tr>
      <th>Name</th>
      <th>Type</th>
      <th>Default</th>
      <th colspan=2>Docs</th>
    </tr>
  </thead>
  <tbody>
    <tr>
  <td style="text-align: left">
    <a id="pub_sub-publish_all-action" href="#pub_sub-publish_all-action">
      <span style="font-family: Inconsolata, Menlo, Courier, monospace;">
        action
      </span>
    </a>
      
  </td>
  <td style="text-align: left">
    <code class="inline">atom</code>
  </td>
  <td style="text-align: left">
    
  </td>
  <td style="text-align: left" colspan=2>
    The name of the action that should be published
  </td>
</tr>

<tr>
  <td style="text-align: left">
    <a id="pub_sub-publish_all-event" href="#pub_sub-publish_all-event">
      <span style="font-family: Inconsolata, Menlo, Courier, monospace;">
        event
      </span>
    </a>
      
  </td>
  <td style="text-align: left">
    <code class="inline">String.t</code>
  </td>
  <td style="text-align: left">
    
  </td>
  <td style="text-align: left" colspan=2>
    The name of the event to publish. Defaults to the action name
  </td>
</tr>

<tr>
  <td style="text-align: left">
    <a id="pub_sub-publish_all-dispatcher" href="#pub_sub-publish_all-dispatcher">
      <span style="font-family: Inconsolata, Menlo, Courier, monospace;">
        dispatcher
      </span>
    </a>
      
  </td>
  <td style="text-align: left">
    <code class="inline">atom</code>
  </td>
  <td style="text-align: left">
    
  </td>
  <td style="text-align: left" colspan=2>
    The module to use as a dispatcher. If none is set, the pubsub module provided is used.
  </td>
</tr>

  </tbody>
</table>





### Introspection

Target: `Ash.Notifier.PubSub.Publication`