Skip to content

Instantly share code, notes, and snippets.

Created September 7, 2018 14:32
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
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)
def broadcast(topic, message) do
PubSub.broadcast(__MODULE__, topic, message)
def subscribe(topic, subscriber) do
PubSub.subscribe(__MODULE__, subscriber, topic)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment