SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Ähnlich wie Phoenix LiveView - Making modern web apps without JavaScript

Progressive Web Apps - Intro & Learnings
Progressive Web Apps - Intro & LearningsProgressive Web Apps - Intro & Learnings
Progressive Web Apps - Intro & LearningsJohannes Weber
 
Electron Firenze 2020: Linux, Windows o MacOS?
Electron Firenze 2020: Linux, Windows o MacOS?Electron Firenze 2020: Linux, Windows o MacOS?
Electron Firenze 2020: Linux, Windows o MacOS?Denny Biasiolli
 
Electron: Linux, Windows or Macos?
Electron: Linux, Windows or Macos?Electron: Linux, Windows or Macos?
Electron: Linux, Windows or Macos?Commit University
 
Building iPad apps with Flex - 360Flex
Building iPad apps with Flex - 360FlexBuilding iPad apps with Flex - 360Flex
Building iPad apps with Flex - 360Flexdanielwanja
 
Make your PWA feel more like an app
Make your PWA feel more like an appMake your PWA feel more like an app
Make your PWA feel more like an appÖnder Ceylan
 
Intro to @viewport & other new Responsive Web Design CSS features
Intro to @viewport & other new Responsive Web Design CSS featuresIntro to @viewport & other new Responsive Web Design CSS features
Intro to @viewport & other new Responsive Web Design CSS featuresAndreas Bovens
 
Firefox OS, the Open Web & WebAPIs - Geek Meet Västerås
Firefox OS, the Open Web & WebAPIs - Geek Meet VästeråsFirefox OS, the Open Web & WebAPIs - Geek Meet Västerås
Firefox OS, the Open Web & WebAPIs - Geek Meet VästeråsRobert Nyman
 
Una web todos los dispositivos.
Una web todos los dispositivos.Una web todos los dispositivos.
Una web todos los dispositivos.philogb
 
Web development - technologies and tools
Web development - technologies and toolsWeb development - technologies and tools
Web development - technologies and toolsYoann Gotthilf
 
Empowering the “Mobile Web” with Chris Mills
Empowering the “Mobile Web” with Chris MillsEmpowering the “Mobile Web” with Chris Mills
Empowering the “Mobile Web” with Chris MillsFITC
 
Empowering the Mobile Web - Mills
Empowering the Mobile Web - MillsEmpowering the Mobile Web - Mills
Empowering the Mobile Web - MillsCodemotion
 
Empowering the "mobile web"
Empowering the "mobile web"Empowering the "mobile web"
Empowering the "mobile web"Chris Mills
 
Web Frontend development: tools and good practices to (re)organize the chaos
Web Frontend development: tools and good practices to (re)organize the chaosWeb Frontend development: tools and good practices to (re)organize the chaos
Web Frontend development: tools and good practices to (re)organize the chaosMatteo Papadopoulos
 
Building Web Sites that Work Everywhere
Building Web Sites that Work EverywhereBuilding Web Sites that Work Everywhere
Building Web Sites that Work EverywhereDoris Chen
 
Building websites with Node.ACS
Building websites with Node.ACSBuilding websites with Node.ACS
Building websites with Node.ACSralcocer
 
Building websites with Node.ACS
Building websites with Node.ACSBuilding websites with Node.ACS
Building websites with Node.ACSRicardo Alcocer
 
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San FranciscoFirefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San FranciscoRobert Nyman
 
Web Directions @media 2010
Web Directions @media 2010Web Directions @media 2010
Web Directions @media 2010Patrick Lauke
 

Ähnlich wie Phoenix LiveView - Making modern web apps without JavaScript (20)

Progressive Web Apps - Intro & Learnings
Progressive Web Apps - Intro & LearningsProgressive Web Apps - Intro & Learnings
Progressive Web Apps - Intro & Learnings
 
Electron Firenze 2020: Linux, Windows o MacOS?
Electron Firenze 2020: Linux, Windows o MacOS?Electron Firenze 2020: Linux, Windows o MacOS?
Electron Firenze 2020: Linux, Windows o MacOS?
 
Electron: Linux, Windows or Macos?
Electron: Linux, Windows or Macos?Electron: Linux, Windows or Macos?
Electron: Linux, Windows or Macos?
 
Building iPad apps with Flex - 360Flex
Building iPad apps with Flex - 360FlexBuilding iPad apps with Flex - 360Flex
Building iPad apps with Flex - 360Flex
 
Working With Canvas
Working With CanvasWorking With Canvas
Working With Canvas
 
Applets
AppletsApplets
Applets
 
Make your PWA feel more like an app
Make your PWA feel more like an appMake your PWA feel more like an app
Make your PWA feel more like an app
 
Intro to @viewport & other new Responsive Web Design CSS features
Intro to @viewport & other new Responsive Web Design CSS featuresIntro to @viewport & other new Responsive Web Design CSS features
Intro to @viewport & other new Responsive Web Design CSS features
 
Firefox OS, the Open Web & WebAPIs - Geek Meet Västerås
Firefox OS, the Open Web & WebAPIs - Geek Meet VästeråsFirefox OS, the Open Web & WebAPIs - Geek Meet Västerås
Firefox OS, the Open Web & WebAPIs - Geek Meet Västerås
 
Una web todos los dispositivos.
Una web todos los dispositivos.Una web todos los dispositivos.
Una web todos los dispositivos.
 
Web development - technologies and tools
Web development - technologies and toolsWeb development - technologies and tools
Web development - technologies and tools
 
Empowering the “Mobile Web” with Chris Mills
Empowering the “Mobile Web” with Chris MillsEmpowering the “Mobile Web” with Chris Mills
Empowering the “Mobile Web” with Chris Mills
 
Empowering the Mobile Web - Mills
Empowering the Mobile Web - MillsEmpowering the Mobile Web - Mills
Empowering the Mobile Web - Mills
 
Empowering the "mobile web"
Empowering the "mobile web"Empowering the "mobile web"
Empowering the "mobile web"
 
Web Frontend development: tools and good practices to (re)organize the chaos
Web Frontend development: tools and good practices to (re)organize the chaosWeb Frontend development: tools and good practices to (re)organize the chaos
Web Frontend development: tools and good practices to (re)organize the chaos
 
Building Web Sites that Work Everywhere
Building Web Sites that Work EverywhereBuilding Web Sites that Work Everywhere
Building Web Sites that Work Everywhere
 
Building websites with Node.ACS
Building websites with Node.ACSBuilding websites with Node.ACS
Building websites with Node.ACS
 
Building websites with Node.ACS
Building websites with Node.ACSBuilding websites with Node.ACS
Building websites with Node.ACS
 
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San FranciscoFirefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
 
Web Directions @media 2010
Web Directions @media 2010Web Directions @media 2010
Web Directions @media 2010
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Kürzlich hochgeladen (20)

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

Phoenix LiveView - Making modern web apps without JavaScript

  • 1. Phoenix LiveView: Making modern web apps without JavaScript Miloš Mošić https://milosmosic.com 1 / 27
  • 2. Who am I? 2 / 27
  • 3. Who am I? Senior Software Engineer at Mainframe 3 / 27
  • 4. Who am I? Senior Software Engineer at Mainframe Worked with Elixir & Phoenix since 2014 4 / 27
  • 5. Who am I? Senior Software Engineer at Mainframe Worked with Elixir & Phoenix since 2014 Helped spread Elixir by introducing it into Evercam 5 / 27
  • 6. 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
  • 9. What is Phoenix LiveView? 9 / 27
  • 10. What is Phoenix LiveView? A brand new library for Phoenix 10 / 27
  • 11. What is Phoenix LiveView? A brand new library for Phoenix Made by the Phoenix creator, Chris McCord 11 / 27
  • 12. What is Phoenix LiveView? A brand new library for Phoenix Made by the Phoenix creator, Chris McCord Not released yet 12 / 27
  • 13. What is Phoenix LiveView? 13 / 27
  • 14. What would you use Phoenix LiveView for? 14 / 27
  • 16. How does it work? 16 / 27
  • 18. 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
  • 19. def deps do [ {:phoenix_live_view, github: "phoenixframework/phoenix_live_view"} ] end https://github.com/phoenixframework/phoenix_live_view 19 / 27
  • 20. defmodule DemoWeb.ImageView do use Phoenix.LiveView end 20 / 27
  • 21. 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
  • 22. 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
  • 23. Example one more time 23 / 27
  • 24. How does it work? 24 / 27
  • 25. Wait, holding an open websocket connection for every single page? 25 / 27