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
390
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
710
Introduction to Erebos: a JavaScript client for Swarm
mosic
1
480
Elixir @ Evercam
mosic
3
1.6k
Other Decks in Programming
See All in Programming
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
0
270
技術記事、AIに書かせるか、自分で書くか? 〜それでも私が自分の手で書く理由〜 / #QiitaConference
jnchito
2
1.5k
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
210
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
400
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
220
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
4
1.5k
Inside Stream API
skrb
1
750
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.7k
エージェンティックRAGにAWSで入門しよう!
har1101
9
1.7k
Go1.27で導入されるジェネリクスメソッドでできること
mackee
0
160
Agentic UI
manfredsteyer
PRO
0
190
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
570
Featured
See All Featured
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
390
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.4k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
200
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.3k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
610
Crafting Experiences
bethany
1
190
A Tale of Four Properties
chriscoyier
163
24k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
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