Last active
June 6, 2020 08:00
-
-
Save tslim/92f5dec7219299ca9a9e7be0283d27e9 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
def mount(_params, session, socket) do | |
{:ok, | |
socket | |
|> subscribe_to_pubsub() | |
... | |
end | |
def handle_info(_message, socket) do | |
{:noreply, fetch_users(socket)} | |
end | |
defp subscribe_to_pubsub(socket) do | |
if connected?(socket), do: PubSub.subscribe(MyApp.PubSub, "topic_name") | |
socket | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment