# `AgentSessionManager.Rendering.Sinks.PubSubSink`
[🔗](https://github.com/nshkrdotcom/agent_session_manager/blob/v0.8.0/lib/agent_session_manager/rendering/sinks/pubsub.ex#L2)

A sink that broadcasts events via Phoenix PubSub.

Ignores rendered text (`write/2`). Broadcasts structured events via
`write_event/3` to one or more PubSub topics derived from the event.

## Options

  * `:pubsub` - The PubSub server (e.g. `MyApp.PubSub`). Required.
  * `:topic` - Static topic string. Mutually exclusive with `:topic_fn`.
  * `:topic_fn` - A function `(event -> String.t() | [String.t()])` that
    returns one or more topics. Mutually exclusive with `:topic`.
  * `:prefix` - Topic prefix. Default `"asm"`.
  * `:scope` - Topic scope when neither `:topic` nor `:topic_fn` is given.
    One of `:session`, `:run`, `:type`. Default `:session`.
  * `:message_wrapper` - Atom used as the first element of the broadcast
    tuple. Default `:asm_event`.
  * `:include_iodata` - Whether to include rendered iodata in the message.
    Default `false`.
  * `:dispatcher` - PubSub dispatcher module. Default `Phoenix.PubSub`.
    Override for testing.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
