-
-
Save dgmcguire/48c7374f9cf548812252c61a4a209717 to your computer and use it in GitHub Desktop.
on first page load `id` will be nil, so it renders all the things, later you can broadcast out a message to subscribers something like `"conversations:123"` and update on the dynmically generated partial
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
<div data-texas="conversations"></div> |
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 ViewModule do | |
def conversations(_conn, id) when is_nil(id) do | |
conversations_html = Database.get_conversations() | |
|> Enum.reduce("", & &2 <> "<div data-texas="conversation" data-texas-id="#{&1.id}">#{&1.text}</div>") | |
~s| | |
<div data-texas="conversations">#{conversations_html}</div> | |
| | |
end | |
def conversations(_conn, id) do | |
~s| | |
<div data-texas="conversation" data-texas-id="#{id}"> | |
Database.get_conversation(id) | |
</div> | |
| | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment