PubSub topics scoped to a mount.
Users of the same mount see each other's changes live; two mounts of the
same library (or two libraries) never share a topic. Messages travel across
the cluster like any Phoenix.PubSub message.
# in a LiveView of the library
PhoenixMountable.PubSub.subscribe(socket.assigns.mount, "items")
# anywhere, after a change
PhoenixMountable.PubSub.broadcast(mount, "items", {:item_updated, item})The PubSub server is the mount's :pubsub option, or the host endpoint's
:pubsub_server.
Summary
Functions
Broadcasts message to the subscribers of topic in the mount, on all nodes.
Like broadcast/3, but not to the caller.
Like broadcast/3, but only on this node.
The PubSub server of the mount.
Subscribes the caller to topic in the mount.
The full topic name for topic in the mount.
Unsubscribes the caller from topic in the mount.
Functions
@spec broadcast(PhoenixMountable.Mount.t(), String.t(), term()) :: :ok | {:error, term()}
Broadcasts message to the subscribers of topic in the mount, on all nodes.
@spec broadcast_from(PhoenixMountable.Mount.t(), String.t(), term()) :: :ok | {:error, term()}
Like broadcast/3, but not to the caller.
@spec local_broadcast(PhoenixMountable.Mount.t(), String.t(), term()) :: :ok
Like broadcast/3, but only on this node.
@spec server!(PhoenixMountable.Mount.t()) :: atom()
The PubSub server of the mount.
@spec subscribe(PhoenixMountable.Mount.t(), String.t()) :: :ok | {:error, term()}
Subscribes the caller to topic in the mount.
@spec topic(PhoenixMountable.Mount.t(), String.t()) :: String.t()
The full topic name for topic in the mount.
@spec unsubscribe(PhoenixMountable.Mount.t(), String.t()) :: :ok
Unsubscribes the caller from topic in the mount.