PubSub¶
Topic-based publish-subscribe for delivering messages to LiveView connections.
Create a PubSub instance and pass it to Listener. LiveViews subscribe
via Socket.subscribe(topic). External actors publish via
pub_sub.publish(topic, message), which delivers to all current
subscribers via InfoReceiver.info.
Constructors¶
create¶
Returns¶
- PubSub tag^
Public Behaviours¶
subscribe¶
Add a subscriber to a topic. Idempotent — subscribing the same connection to the same topic twice has no additional effect.
Parameters¶
- topic: String val
- subscriber: InfoReceiver tag
unsubscribe¶
Remove a subscriber from a topic.
Parameters¶
- topic: String val
- subscriber: InfoReceiver tag
unsubscribe_all¶
Remove a subscriber from all topics. Called automatically by the connection actor when a WebSocket closes.
Parameters¶
- subscriber: InfoReceiver tag
publish¶
Send a message to all subscribers of a topic.