Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Phoenix LiveView - Making modern web apps witho...
Search
Miloš Mošić
May 30, 2019
Programming
400
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Phoenix LiveView - Making modern web apps without JavaScript
https://www.meetup.com/elixirbelgrade/events/261344984/
Miloš Mošić
May 30, 2019
More Decks by Miloš Mošić
See All by Miloš Mošić
Elixir_and_Blockchain_-_a_Perfect_Match.pdf
mosic
0
720
Introduction to Erebos: a JavaScript client for Swarm
mosic
1
490
Elixir @ Evercam
mosic
3
1.6k
Other Decks in Programming
See All in Programming
使いながら育てる Claude Code — 開発フローの1コマンド化 × 繰り返し指摘の自動仕組み化
shiki_kakaku
0
1.7k
複数の Claude Code が"放置"されてしまう問題をCLI ダッシュボードを自作して解決した話
sumihiro3
1
670
言語を使う側から、作る側へ。 自作 Lisp で得た新たな気づき。
andpad
0
160
TSX の <Hoge<Fuga>> という構文に驚いた話 / tsx-type-argument-syntax
kanaru0928
0
210
ドリフトを絶対に許さない(?)CDK運用 / CDK Ops with Zero Tolerance for Drifts (?)
akihisaikeda
1
180
夏だ!祭りだ!祭りとはドメインモデリングでは?
ryugen04
0
190
<title><a id="</title>君はこのHTMLをパースできるか"></a></title> #雑LT_study
pizzacat83
0
140
GDG Korea Android: 2026 I/O Extended ~ What's new in Android development tools
pluu
0
220
Welcome to the "Parametricity" 🏙️ − Generic だけど Specific な世界 −
guvalif
PRO
1
200
ソフトウェア設計に溶けるインフラ ― AWS CDK のインフラ認識論
konokenj
3
760
S3 を使うアプリケーションをローカル完結で動かすことに全力を注いでみた / Running S3 Apps Offline
contour_gara
0
390
仕様書を書く前にハーネスを作る - Agent Native開発は「探索を速く、判定を固く」
gotalab555
4
1.6k
Featured
See All Featured
Statistics for Hackers
jakevdp
799
230k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
660
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
Unsuck your backbone
ammeep
672
58k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
760
From π to Pie charts
rasagy
0
260
The Cost Of JavaScript in 2023
addyosmani
55
10k
Everyday Curiosity
cassininazir
0
270
Code Reviewing Like a Champion
maltzj
528
40k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
210
Transcript
Phoenix LiveView: Making modern web apps without JavaScript Miloš Mošić
https://milosmosic.com 1 / 27
Who am I? 2 / 27
Who am I? Senior Software Engineer at Mainframe 3 /
27
Who am I? Senior Software Engineer at Mainframe Worked with
Elixir & Phoenix since 2014 4 / 27
Who am I? Senior Software Engineer at Mainframe Worked with
Elixir & Phoenix since 2014 Helped spread Elixir by introducing it into Evercam 5 / 27
Who am I? Senior Software Engineer at Mainframe Worked with
Elixir & Phoenix since 2014 Helped spread Elixir by introducing it into Evercam Gave a talk at the first Elixir Conf EU 6 / 27
What is Elixir? 7 / 27
What is Phoenix? 8 / 27
What is Phoenix LiveView? 9 / 27
What is Phoenix LiveView? A brand new library for Phoenix
10 / 27
What is Phoenix LiveView? A brand new library for Phoenix
Made by the Phoenix creator, Chris McCord 11 / 27
What is Phoenix LiveView? A brand new library for Phoenix
Made by the Phoenix creator, Chris McCord Not released yet 12 / 27
What is Phoenix LiveView? 13 / 27
What would you use Phoenix LiveView for? 14 / 27
Killing JavaScript 15 / 27
How does it work? 16 / 27
Simple example 17 / 27
defmodule DemoWeb.ImageView do use Phoenix.LiveView def render(assigns) do ~L""" <form
phx-change="update"> <input type="range" min="10" max="630" name="width" value="<%= @width %>" /> <%= @width %>px <fieldset> White <%= radio_tag(name: :bg, value: "white", checked: @bg) %> Black <%= radio_tag(name: :bg, value: "black", checked: @bg) %> Blue <%= radio_tag(name: :bg, value: "blue", checked: @bg) %> </fieldset> </form> <br/> <img src="/images/phx.png" width="<%= @width %>" style="background: <%= @bg %>;" /> """ end def radio_tag(assigns) do ~L""" <input type="radio" name="<%= @name %>" value="<%= @value %>" <%= if @value == @checked, do: "checked" %> /> """ end def mount(_session, socket) do {:ok, assign(socket, width: 100, bg: "white")} end def handle_event("update", %{"width" => width, "bg" => bg}, socket) do {:noreply, assign(socket, width: String.to_integer(width), bg: bg)} end end 18 / 27
def deps do [ {:phoenix_live_view, github: "phoenixframework/phoenix_live_view"} ] end https://github.com/phoenixframework/phoenix_live_view
19 / 27
defmodule DemoWeb.ImageView do use Phoenix.LiveView end 20 / 27
def render(assigns) do ~L""" <form phx-change="update"> <input type="range" min="10" max="630"
name="width" value="<%= @width %>" /> <%= @width %>px <fieldset> White <%= radio_tag(name: :bg, value: "white", checked: @bg) %> Black <%= radio_tag(name: :bg, value: "black", checked: @bg) %> Blue <%= radio_tag(name: :bg, value: "blue", checked: @bg) %> </fieldset> </form> <br/> <img src="/images/phx.png" width="<%= @width %>" style="background: <%= @bg %>;" /> """ end 21 / 27
def radio_tag(assigns) do ~L""" <input type="radio" name="<%= @name %>" value="<%=
@value %>" <%= if @value == @checked, do: "checked" %> /> """ end def mount(_session, socket) do {:ok, assign(socket, width: 100, bg: "white")} end def handle_event("update", %{"width" => width, "bg" => bg}, socket) do {:noreply, assign(socket, width: String.to_integer(width), bg: bg)} end 22 / 27
Example one more time 23 / 27
How does it work? 24 / 27
Wait, holding an open websocket connection for every single page?
25 / 27
https://phoenixframework.org/blog/the-road-to-2-million-websocket-connections 26 / 27
Thank You! Questions? 27 / 27