
herminiotorres
Programming Phoenix LiveView - Version B5.0
On Chapter 3 - Page 78, the beginning of the page has this code here:
@doc """
Maybe it is missing to put the Pento context before Catalog.Product.Query?
"""
defmodule Catalog.Product.Query do
...
def base_product_query, do: Product
def cheaper_than(query, price), do: from in query, where...
def cheap_product_skus(price)
base_product_query()
|> chaper_than(price)
|> skus
end
...
end
And for the code almost to the bottom, has some typos. Like:
defmodule Pento.Catalog do
alias Catalog.Product.Query
alias Pento.Repo
def run_query(query) do
{:ok, list} = Repo.all(query)
list
end
def send_sale_skus(query) do
query
|> Product.cheap_product_skus(25.00) # Typo: Query.cheap_product_skus(25.00)
|> run_query
|> Service.send_bargains # Question: the name of the module it is only Service?
end
end
Also, for the next page 79, has more typos too, like:
defmodule Pento.Catalog do
alias Catalog.Product.Query
alias Pento.Repo
@doc """
For the Repo.all API, has only three options:
1. Empty List without any items.
2. List with one or more items.
3. Query doesn't work and raise an error.
"""
def run_query(query) do
Repo.all(query)
end
def send_sale_skus(query) do
query
|> Product.cheap_product_skus(25.00) # Typo: Query.cheap_product_skus(25.00)
|> run_query
end
def send_sale_skus(query)
with {:ok, products} <- send_sale_skus(query), # this line of code here, never pattern matching
{:ok, response} <- Service.send_bargains(products) do # when this line of code it fails? Returns as a tuple with {:error, reason} ?
response
else
# if some error or cas doesn't pattern match in with conditions it will failure here a raise an error with unclause matching.
{:error, reason} ->
IO.puts "Error sending sale skus: #{reason}"
end
end
end
After words this is my feedback even these code as an example, and not intended to use. Besides, I use common comments as #
, and some others I use @doc
to get my point of view.
Marked As Solved

SophieDeBenedetto
Author of Programming Phoenix LiveView
Thank you for catching these! We’ll fix them for the next release
Also Liked

SophieDeBenedetto
Author of Programming Phoenix LiveView
Thank you so much for sharing this feedback @herminiotorres! I’ve made some changes to fix the typo and to provide a better example of when to use with
statements in your Phoenix context. You’ll find those changes in the next release
1
Popular Pragmatic Bookshelf topics

Some minor things in the paper edition that says “3 2020” on the title page verso, not mentioned in the book’s errata online:
p. 186 But...
New

page 37
ANTLRInputStream input = new ANTLRInputStream(is);
as of ANTLR 4 .8 should be:
CharStream stream = CharStreams.fromStream(i...
New

Many tasks_proj/tests directories exist in chapters 2, 3, 5 that have tests that use the custom markers smoke and get, which are not decl...
New

Title: Web Development with Clojure, Third Edition, pg 116
Hi - I just started chapter 5 and I am stuck on page 116 while trying to star...
New

Title: Hands-on Rust: question about get_component (page 295)
(feel free to respond. “You dug you’re own hole… good luck”)
I have somet...
New

Hi! I know not the intentions behind this narrative when called, on page XI:
mount() |> handle_event() |> render()
but the correc...
New

I’m running Android Studio “Arctic Fox” 2020.3.1 Patch 2, and I’m embarrassed to admit that I only made it to page 8 before running into ...
New

AWDWR 7, page 152, page 153:
Hello everyone,
I’m a little bit lost on the hotwire part. I didn’t fully understand it.
On page 152 @rub...
New

Hi, I’m working on the Chapter 8 of the book.
After I add add the point_offset, I’m still able to see acne:
In the image above, I re...
New

I’ve got to the end of Ch. 11, and the app runs, with all tabs displaying what they should – at first. After switching around between St...
New
Other popular topics

Reading something? Working on something? Planning something? Changing jobs even!?
If you’re up for sharing, please let us know what you’...
New

@AstonJ prompted me to open this topic after I mentioned in the lockdown thread how I started to do a lot more for my fitness.
https://f...
New

Design and develop sophisticated 2D games that are as much fun to make as they are to play. From particle effects and pathfinding to soci...
New

Thanks to @foxtrottwist’s and @Tomas’s posts in this thread: Poll: Which code editor do you use? I bought Onivim! :nerd_face:
https://on...
New

I ended up cancelling my Moonlander order as I think it’s just going to be a bit too bulky for me.
I think the Planck and the Preonic (o...
New

I am asking for any distro that only has the bare-bones to be able to get a shell in the server and then just install the packages as we ...
New

Learn different ways of writing concurrent code in Elixir and increase your application's performance, without sacrificing scalability or...
New

Continuing the discussion from Thinking about learning Crystal, let’s discuss - I was wondering which languages don’t GC - maybe we can c...
New

API 4
Path:
/user/following/
Method:
GET
Description:
Returns the list of all names of people whom the user follows
Response
[
{ ...
New

If you’re getting errors like this:
psql: error: connection to server on socket “/tmp/.s.PGSQL.5432” failed: No such file or directory ...
New
Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /rails
- /js
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /ash
- /vscode
- /opensuse
- /centos
- /php
- /deepseek
- /html
- /zig
- /scala
- /debian
- /nixos
- /lisp
- /agda
- /textmate
- /sublime-text
- /react-native
- /kubuntu
- /arch-linux
- /revery
- /ubuntu
- /django
- /spring
- /manjaro
- /diversity
- /nodejs
- /lua
- /julia
- /slackware
- /c
- /neovim