# `Condukt.Notifiers.PubSub`
[🔗](https://github.com/tuist/tuist/blob/condukt@3.0.0/condukt/lib/condukt/notifiers/pub_sub.ex#L1)

Publishes session events over `Phoenix.PubSub`.

This is how one session reaches many viewers, including viewers connected to
other nodes: the session broadcasts once and PubSub delivers to everyone
subscribed to its topic, wherever they are.

    Condukt.run(MyApp.Agent, "hello",
      notifier: {Condukt.Notifiers.PubSub, server: MyApp.PubSub}
    )

Subscribers listen on the session's topic and receive
`{:condukt_event, session_id, event}`:

    Phoenix.PubSub.subscribe(MyApp.PubSub, Condukt.Notifiers.PubSub.topic(session_id))

Numbered view changes go to a topic of their own, so subscribers of the
event topic receive nothing new. They arrive as
`{:condukt_change, session_id, epoch, seq, change}`, the same message
`Condukt.Session.watch/1` sends locally. Subscribe first, then fetch the
view, and apply each change with `Condukt.Session.View.advance/4`:

    Phoenix.PubSub.subscribe(MyApp.PubSub, Condukt.Notifiers.PubSub.changes_topic(session_id))
    view = Condukt.Session.view(session)

## Options

  * `:server` - the PubSub server name (required)
  * `:prefix` - topic prefix, `"condukt:session:"` by default

Requires `:phoenix_pubsub`, which Condukt declares as optional so projects
that fan out some other way do not carry it.

# `changes_topic`

The topic a session publishes its numbered view changes on.

# `topic`

The topic a session publishes on.

---

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