Hi,
I have a weird issue, I am trying to follow the guide for the LiveView to learn about it but I have an issue with a very simple usecase. I would like to have a counter incremented by my backend.
This is my LiveView:
defmodule FooWeb.BarLive do
use FooWeb, :live_view
def render(assigns) do
~H"""
<div>Test <%= @counter %></div>
"""
end
def mount(_params, _session, socket) do
if connected?(socket), do: Process.send_after(self(), :update, 1000)
{:ok, assign(socket, :counter, 0)}
end
def handle_info(:update, socket) do
Process.send_after(self(), :update, 1000)
{:noreply, assign(socket, :counter, socket.assigns.counter + 1)}
end
end
I would expect to see my counter going up every seconds, instead in stays at 0 and I get this error after the first second:
[debug] warning: undefined handle_info in FooWeb.BarLive. Unhandled message: :update
I am using LiveView 0.18.11 (from the lock file).
I am pretty sure I am holding it wrong, any idea?