Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Created September 7, 2018 14:32
Show Gist options
  • Save deque-blog/4fc11e6c548f9d986df620f1c8b1c2e0 to your computer and use it in GitHub Desktop.
Save deque-blog/4fc11e6c548f9d986df620f1c8b1c2e0 to your computer and use it in GitHub Desktop.
defmodule PubSub do
alias Phoenix.PubSub
def start_link() do
import Supervisor.Spec, warn: false
children = [
supervisor(Phoenix.PubSub.PG2, [__MODULE__, []]),
]
Supervisor.start_link(children, strategy: :one_for_one)
end
def broadcast(topic, message) do
PubSub.broadcast(__MODULE__, topic, message)
end
def subscribe(topic, subscriber) do
PubSub.subscribe(__MODULE__, subscriber, topic)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment