drm v0.1.2 Drm.Hub View Source
Pub-sub hub
Subscription is done with a pattern.
Example:
Hub.subscribe("global", %{count: count} when count > 42) Hub.publish("global", %{count: 45, message: "You rock!"})
Link to this section Summary
Functions
Publishes the term to all subscribers that matches it Returns the number of subscribers that got the message
Convenience macro for subscribing without the need to unquote the pattern.
Subscribes to the quoted pattern in the given channel_name
Get all subscribers from channel
Unsubscribes using the reference returned on subscribe
Link to this section Functions
publish(channel_name, term)
View Source
publish(String.t(), any()) :: non_neg_integer()
publish(String.t(), any()) :: non_neg_integer()
Publishes the term to all subscribers that matches it Returns the number of subscribers that got the message
subscribe(channel_name, pattern, options \\ []) View Source (macro)
Convenience macro for subscribing without the need to unquote the pattern.
example:
Hub.subscribe("global", %{count: count} when count > 42)
subscribe_quoted(channel_name, quoted_pattern, options \\ []) View Source
Subscribes to the quoted pattern in the given channel_name
example:
Hub.subscribe("global", quote do: %{count: count} when count > 42)
subscribers(channel_name)
View Source
subscribers(String.t()) :: [Drm.Subscriber.t()]
subscribers(String.t()) :: [Drm.Subscriber.t()]
Get all subscribers from channel
traverse_pin(term, bindings) View Source
unsubscribe(ref) View Source
Unsubscribes using the reference returned on subscribe