Programming Phoenix LiveView

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

If you haven’t been following closely, it might seem like LiveView came suddenly, like a new seedling that breaks through the soil surface overnight. That narrative lacks a few important details, like all of the slow germination and growth that happens out of sight. Chris McCord, the creator of Phoenix, worked on Ruby on Rails before coming over to the Elixir community. More and more often, his consultancy was asked to use Ruby on Rails to build dynamic single-page apps (SPAs). He tried to build a server-side framework on top of the Ruby on Rails infrastructure, much like LiveView, that would allow him to meet these demands for interactivity. But Chris recognized that the Ruby infrastructure was not robust enough to support his idea. He needed better reliability, higher throughput, and more even performance. He shopped around for a more appropriate language and infrastructure, and found Elixir. The Phoenix team was able to build jаvascript features into LiveView that automate the process of changing a user interface on a socket connection. In LiveView, programmers would find a beautiful programming model based on tested concepts, and one that provided jаvascript infrastructure so developers didn’t need to write their own jаvascript. This book is for advanced beginners and intermediate programmers who want to build web applications using Phoenix LiveView. In it, you’ll learn the basic abstractions that make LiveView work, and you’ll explore techniques that help you organize your code into layers that make sense. We will try not to bore you with a tedious feature-by-feature march. Instead, we’ll help you grasp LiveView by building a nontrivial application together.

Author(s): Bruce A. Tate, Sophie DeBenedetto
Series: The Pragmatic Programmers
Publisher: The Pragmatic Bookshelf, LLC
Year: 2023

Language: English
Pages: 412

Programming Phoenix LiveView
About the Pragmatic Bookshelf
Table of Contents
Change History
B9.0 March 21, 2023
B8.0 October 14th, 2022
B7.0 March 30th, 2022
B6.0 Jan 28th, 2022
B5.0 July 1st, 2021
B4.0 April 29th, 2021
B3.0 April 2nd, 2021
B2.0 March 11th, 2021
B1.0: February 24, 2021
Introduction
Is This Book for You?
About this Book
Online Resources
Chapter 1: Get To Know LiveView
Single-Page Apps are Distributed Systems
LiveView Makes SPAs Easy
Program LiveView Like a Professional
Install Elixir, Postgres, Phoenix, and LiveView
Create a Phoenix Project
The LiveView Lifecycle
Build a Simple LiveView
LiveView Transfers Data Efficiently
Your Turn
Part 1: Code Generation
Chapter 2: Phoenix and Authentication
CRC: Constructors, Reducers, and Converters
Phoenix is One Giant Function
Generate The Authentication Layer
Explore Accounts from IEx
Protect Routes with Plugs
Authenticate The Live View
Access Session Data in The Live View
Your Turn
Chapter 3: Generators: Contexts and Schemas
Get to Know the Phoenix Live Generator
Run the Phoenix Live Generator
Understand The Generated Core
Understand The Generated Boundary
Boundary, Core, or Script?
Your Turn
Chapter 4: Generators: Live Views and Templates
Application Inventory
Mount and Render the Product Index
Use Components to Render HTML
Handle Change for the Product Edit
Manage Change with a Form Component
Your Turn
Part 2: LiveView Composition
Chapter 5: Forms and Changesets
Model Change with Changesets
Model Change with Schemaless Changesets
Use Schemaless Changesets in LiveView
LiveView Form Bindings
Live Uploads
Your Turn
Chapter 6: Function Components
The Survey
Organize Your LiveView with Components
Build The Survey C ontext
Organize The Application Core and Boundary
Build The Survey Live View
Build a Simple Function Component
Build the Demographic Show Function Component
Your Turn
Chapter 7: Live Components
Build the Live Demographic Form Component
Manage Component State
Build The Ratings Components
List Ratings
Show a Rating
Show the Rating Form
Your Turn
Part 3: Extend LiveView
Chapter 8: Build an Interactive Dashboard
The Plan
Define The Admin.Dashboar dLive LiveView
Represent Dashboard Concepts with Components
Fetch Survey Results Data
Initialize the Admin.Surv eyResultsLive Component State
Render SVG Charts with Contex
Add Filters to Make Charts Interactive
Refactor Chart Code with Macros
Your Turn
Chapter 9: Build a Distributed Dashboard
LiveView and Phoenix Messaging Tools
Track Real-Time Survey Results with PubSub
Track Real-Time User Activity with Presence
Display User Tracking
Your Turn
Chapter 10: Test Your Live Views
What Makes CRC Code Testable?
Unit Test Test Survey Results State
Integration Test LiveView Interactions
Verify Distributed Realtime Updates
Your Turn
Part 4: Graphics and Custom Code Organization
Chapter 11: Build the Game Core
The Plan
Represent a Shape With Points
Group Points Together in Shapes
Track and Place a Pentomino
Track a Game in a Board
Your Turn
Chapter 12: Render Graphics With SVG
Plan the Presentation Layer
Define a Skinny GameLive View
Render Points with SVG
Compose With Components
Put It All Together
Your Turn
Chapter 13: Establish Boundaries and APIs
It’s Alive: Plan User Interactions
Process User Interactions in the Core
Build a Game Boundary Layer
Extend the Game Live View
Add Help with JavaScript
Build a Picker to Control Navigation
Your Turn
Bibliography