Optional Phoenix.PubSub integration for cross-node events and LiveView support.
This module provides publish/subscribe functionality for room events when Phoenix.PubSub is available. All functions gracefully handle cases where PubSub is not configured.
Usage
defmodule MyApp.Messaging do
use Jido.Messaging, persistence: Jido.Messaging.Persistence.ETS,
pubsub: MyApp.PubSub
end
# Subscribe to room events
MyApp.Messaging.subscribe("room_123")
# Events received:
# {:message_added, %Message{}}
# {:participant_joined, %Participant{}}
# {:participant_left, participant_id}
Summary
Functions
Broadcast an event to all subscribers of a room.
Check if PubSub is configured for the given instance module.
Check if Phoenix.PubSub is available at runtime.
Subscribe to events for a room.
Generate the topic string for a room.
Unsubscribe from events for a room.
Functions
Broadcast an event to all subscribers of a room.
Returns :ok on success, or {:error, :not_configured} if PubSub is not configured.
Check if PubSub is configured for the given instance module.
@spec pubsub_available?() :: boolean()
Check if Phoenix.PubSub is available at runtime.
Subscribe to events for a room.
Returns :ok on success, or {:error, :not_configured} if PubSub is not configured.
Generate the topic string for a room.
Unsubscribe from events for a room.
Returns :ok on success, or {:error, :not_configured} if PubSub is not configured.