| [`module`](#pub_sub-module){: #pub_sub-module .spark-required} | `atom` | | The module to call `broadcast/3` on e.g module.broadcast(topic, event, message). |
| [`prefix`](#pub_sub-prefix){: #pub_sub-prefix } | `String.t` | | A prefix for all pubsub messages, e.g `users`. A message with `created` would be published as `users:created` |
| [`broadcast_type`](#pub_sub-broadcast_type){: #pub_sub-broadcast_type } | `:notification \| :phoenix_broadcast \| :broadcast` | `:notification` | What shape the event payloads will be in. See |
| [`name`](#pub_sub-name){: #pub_sub-name } | `atom` | | A named pub sub to pass as the first argument to broadcast. |
## 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
| Name | Type | Default | Docs |
|------|------|---------|------|
| [`action`](#pub_sub-publish-action){: #pub_sub-publish-action .spark-required} | `atom` | | The name of the action that should be published |
| [`previous_values?`](#pub_sub-publish-previous_values?){: #pub_sub-publish-previous_values? } | `boolean` | `false` | Whether or not to publish messages with both the new values and the old values for referencing changed attributes |
| [`event`](#pub_sub-publish-event){: #pub_sub-publish-event } | `String.t` | | The name of the event to publish. Defaults to the action name |
| [`dispatcher`](#pub_sub-publish-dispatcher){: #pub_sub-publish-dispatcher } | `atom` | | The 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
```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
| Name | Type | Default | Docs |
|------|------|---------|------|
| [`type`](#pub_sub-publish_all-type){: #pub_sub-publish_all-type } | `:create \| :update \| :destroy` | | Publish on all actions of a given type |
| [`previous_values?`](#pub_sub-publish_all-previous_values?){: #pub_sub-publish_all-previous_values? } | `boolean` | `false` | Whether or not to publish messages with both the new values and the old values for referencing changed attributes |
| [`event`](#pub_sub-publish_all-event){: #pub_sub-publish_all-event } | `String.t` | | The name of the event to publish. Defaults to the action name |
| [`dispatcher`](#pub_sub-publish_all-dispatcher){: #pub_sub-publish_all-dispatcher } | `atom` | | The module to use as a dispatcher. If none is set, the pubsub module provided is used. |