Phoenix·Phoenix essentials

LiveView

LiveView keeps state on the server and updates the page over a socket.

Advanced 10 min read Lesson 4 of 150 Challenge included
What you will be able to do
  • Use Phoenix.LiveView.
  • Handle events with handle_event.
  • Render with ~H sigil.

In plain English

LiveView keeps state on the server and updates the page over a socket.

  • Use Phoenix.LiveView.
  • Handle events with handle_event.
  • Render with ~H sigil.
counter_live.exELIXIR
def mount(_params, _session, socket) do
  {:ok, assign(socket, count: 0)}
end

def handle_event("inc", _, socket) do
  {:noreply, update(socket, :count, &(&1 + 1))}
end
Your turn

Explain it back

Easy

Answer from memory: Where does LiveView keep state?

TEXT · starter
Your answer…
Check your understanding before moving on.
Knowledge checkQuestion 1

Where does LiveView keep state?

Select an answer to continue
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Next: Deploy
Lesson 4 of 150 · 0% of course