Skip to content

Instantly share code, notes, and snippets.

@KamilLelonek
Created September 18, 2018 22:59
Show Gist options
  • Save KamilLelonek/baa6155431674edd1d17503aea4574fe to your computer and use it in GitHub Desktop.
Save KamilLelonek/baa6155431674edd1d17503aea4574fe to your computer and use it in GitHub Desktop.
defmodule PostgresPubSub.Listener do
use GenServer
def child_spec(opts) do
%{
id: __MODULE__,
start: {__MODULE__, :start_link, [opts]}
}
end
def start_link(opts \\ []),
do: GenServer.start_link(__MODULE__, opts)
def init(opts) do
with {:ok, _pid, _ref} <- PostgresPubSub.Repo.listen("accounts_changed") do
{:ok, opts}
else
error -> {:stop, error}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment