joepstender

joepstender

Programming Phoenix LiveView: errata and remarks Version B2.0

The generated iex result below should list products instead of product for the metadata. (page 67)

iex> product = %Product{}
 %Pento.Catalog.Product{
 __meta__: #Ecto.Schema.Metadata<:built, "product">,
 …
}

The mount/3 function that is generated is different from the one used in the example, this might be confusing if you are familiar with the way pipes are used in Elixir. (Page 87)

def mount(_params, _session, socket) do
 {:ok,
 socket
 |> assign(:greeting, "Welcome to Pento!") # add this line
 |> assign(:products, list_products())}
end

Instead of

{:ok, assign(socket, :products, list_products())}

These few lines of code are a bit different from what we’ve seen before,… (Page 98)

Actually we have already seen this exact code 2 pages earlier, starting on page 96.
Suggestion: introduce the repeated code with: “Here’s the line of code that calls the modal component from the index template again:”

That means the component must implement a handle_event/3 function for the “close” event, which is does here: (Page 103)

Should be “… which it does here:”

Notice there’s an :id key, as well as a :component key that specifies the FormComponent (Page 106)

It is unclear what the :component_key is.

Marked As Solved

SophieDeBenedetto

SophieDeBenedetto

Author of Programming Phoenix LiveView

Hello! Thank you so much for your feedback, we really appreciate it :slight_smile:

Let’s go through it one thing as a time:

The generated iex result below should list products instead of product for the metadata. (page 67)

You are totally right! You’ll find this fixed in the next Beta release. Thanks for pointing it out :slight_smile:

The mount/3 function that is generated is different from the one used in the example, this might be confusing if you are familiar with the way pipes are used in Elixir. (Page 87)

Good catch! In fact this code snippet does change the way the generated mount/3 function calls assign in order to add the products to the socket. You’ll find this updated for clarity in the next Beta release.

Actually we have already seen this exact code 2 pages earlier, starting on page 96.
Suggestion: introduce the repeated code with: “Here’s the line of code that calls the modal component from the index template again :”

Yep you are right that we’ve shown you this code snippet already. I’ll add some language to clarify that in the next release.

Should be “… which it does here:”

Nice catch! Will fix in the next release.

It is unclear what the :component_key is.

The :component key points to a value of the component that will be rendered in the modal–FormComponent. I’ll add some language to clarify this but we also go into greater detail just a bit further on in the chapter.

Thanks again!

Where Next?

Popular Pragmatic Bookshelf topics Top

jimmykiang
This test is broken right out of the box… — FAIL: TestAgent (7.82s) agent_test.go:77: Error Trace: agent_test.go:77 agent_test.go:...
New
simonpeter
When I try the command to create a pair of migration files I get an error. user=&gt; (create-migration "guestbook") Execution error (Ill...
New
joepstender
The generated iex result below should list products instead of product for the metadata. (page 67) iex&gt; product = %Product{} %Pento....
New
adamwoolhether
When trying to generate the protobuf .go file, I receive this error: Unknown flag: --go_opt libprotoc 3.12.3 MacOS 11.3.1 Googling ...
New
jskubick
I think I might have found a problem involving SwitchCompat, thumbTint, and trackTint. As entered, the SwitchCompat changes color to hol...
New
brunogirin
When trying to run tox in parallel as explained on page 151, I got the following error: tox: error: argument -p/–parallel: expected one...
New
hazardco
On page 78 the following code appears: &lt;%= link_to ‘Destroy’, product, class: ‘hover:underline’, method: :delete, data: { confirm...
New
EdBorn
Title: Agile Web Development with Rails 7: (page 70) I am running windows 11 pro with rails 7.0.3 and ruby 3.1.2p20 (2022-04-12 revision...
New
bjnord
Hello @herbert ! Trying to get the very first “Hello, Bracket Terminal!" example to run (p. 53). I develop on an Amazon EC2 instance runn...
New
roadbike
From page 13: On Python 3.7, you can install the libraries with pip by running these commands inside a Python venv using Visual Studio ...
New

Other popular topics Top

axelson
I’ve been really enjoying obsidian.md: It is very snappy (even though it is based on Electron). I love that it is all local by defaul...
New
Exadra37
Please tell us what is your preferred monitor setup for programming(not gaming) and why you have chosen it. Does your monitor have eye p...
New
PragmaticBookshelf
Rust is an exciting new programming language combining the power of C with memory safety, fearless concurrency, and productivity boosters...
New
PragmaticBookshelf
Build highly interactive applications without ever leaving Elixir, the way the experts do. Let LiveView take care of performance, scalabi...
New
AstonJ
Continuing the discussion from Thinking about learning Crystal, let’s discuss - I was wondering which languages don’t GC - maybe we can c...
New
AstonJ
If you want a quick and easy way to block any website on your Mac using Little Snitch simply… File &gt; New Rule: And select Deny, O...
New
husaindevelop
Inside our android webview app, we are trying to paste the copied content from another app eg (notes) using navigator.clipboard.readtext ...
New
PragmaticBookshelf
Author Spotlight: Karl Stolley @karlstolley Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Karl ...
New
PragmaticBookshelf
A Ruby-Centric Chat with Noel Rappin @noelrappin Once you start noodling around with Ruby you quickly figure out, as Noel Rappi...
New
AstonJ
This is cool! DEEPSEEK-V3 ON M4 MAC: BLAZING FAST INFERENCE ON APPLE SILICON We just witnessed something incredible: the largest open-s...
New

Sub Categories: