Is anyone else having trouble with Phoenix Liveview’s phx-update? I feel like I must be doing something dumb or missing something key in the docs (https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html#module-dom-patching-and-temporary-assigns).
This code doesn’t do the phx-update/append action, instead it seems to behave like it would if the phx-update term weren’t set.
defmodule LiveMessageTestWeb.TestMessage do
use Phoenix.LiveView
def render(assigns) do
~L"""
<div id="chat-messages" phx-update="append">
<%= for message <- @messages do %>
<p><%= message %></p>
<% end %>
</div>
"""
end
def mount(_session, socket) do
Process.send_after(self(), :ping, 100)
socket = assign(socket, messages: [])
{:ok, socket, temporary_assigns: [messages: []]}
end
def handle_info(:ping, socket) do
Process.send_after(self(), :ping, 200)
new_value = Enum.shuffle(?A..?Z) |> List.to_string
{:noreply, assign(socket, :messages, [new_value])}
end
end