Created
September 7, 2018 14:32
-
-
Save deque-blog/4fc11e6c548f9d986df620f1c8b1c2e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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