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
500
Elixir @ Evercam
mosic
3
1.6k
Other Decks in Programming
See All in Programming
Hono + Inertia + React で LP を構築した話
oukayuka
2
190
関東Kaggler会_NVIDIA_Nemotron_コンペ_振り返り
rick_ds
0
740
仕様書を書く前にハーネスを作る - Agent Native開発は「探索を速く、判定を固く」
gotalab555
5
1.8k
バグを直したら useEffect が消えた
colorful12
3
780
不幸な GC
chencmd
0
830
初めての模倣学習とVLA
natsutan
0
330
AI Engineeringは、AIプロダクトだけのものか? 〜AIがソフトウェアを作る時代の新しい当たり前〜 / No AI in your product. AI Engineering in your development.
rkaga
5
550
片田舎のおっさん、 Swift Buildのダイアモンド問題解決の不具合修正PRを出すが、解決方法がキャッシュをしないようにすることであり、ビルド時間が伸びると言われてマージされないので高速化もする/swiftbuild
yimajo
0
320
React本体のコードリーディング
high_g_engineer
1
160
コンパウンドプロダクト開発のためのローカルプロセスマネージャー再発明 #layerxgo
izumin5210
0
540
実装をデザインガイドラインに追従させるための取り組み / 260731-dip-mosh-design-system
dachi023
0
7.9k
ドリフトを絶対に許さない(?)CDK運用 / CDK Ops with Zero Tolerance for Drifts (?)
akihisaikeda
1
250
Featured
See All Featured
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
450
GitHub's CSS Performance
jonrohan
1033
470k
Mind Mapping
helmedeiros
PRO
1
340
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
430
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
390
How to Ace a Technical Interview
jacobian
281
24k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
400
Designing for Timeless Needs
cassininazir
1
460
WCS-LA-2024
lcolladotor
0
810
Ethics towards AI in product and experience design
skipperchong
2
350
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
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