Phoenix Handle Info Self Example: Revision history

Jump to: navigation, search

Diff selection: Mark the radio buttons of the revisions to compare and hit enter or the button at the bottom.
Legend: (cur) = difference with latest revision, (prev) = difference with preceding revision, m = minor edit.

10 May 2025

  • curprev 05:1505:15, 10 May 2025Admin talk contribs 793 bytes +793 Created page with "<source> defmodule AppWeb.Sandbox do use AppWeb, :live_view require Logger def mount(_params, _session, socket) do {:ok, assign(socket, :count, 0)} end def handle_event("increment", _params, socket) do # Send a message to ourselves after 1000 milliseconds (1 second) Process.send_after(self(), :delayed_increment, 1000) {:noreply, socket} end def handle_info(:delayed_increment, socket) do new_count = socket.assigns.count + 1 Logger...."