creminology

creminology

Real Time Phoenix Errata P17: Getting first sample working with Phoenix 1.6.x

Skimming ahead, much of the following is explained in Chapter 3, but new readers (like me!) will hit a roadblock in Chapter 2 with their first app not working without making some changes under the latest versions of Phoenix.

mix phx.new hello_sockets --no-ecto --no-live --no-dashboard --no-mailer
cd hello_sockets
mix phx.gen.channel Ping

Permit the generator to create the default socket handler, and follow the instructions to add it to the HelloSocketsWeb.Endpoint module. Also follow the instructions to import user_socket.js by uncommenting the line in assets/js/app.js.

Inside assets/js/user.socket.js, change the name of the channel being joined from “room:42” to “ping”.

Inside HelloSocketsWeb.PingChannel, change the first parameter of join/3 from “ping:lobby” to “ping”.

Inside HelloSocketsWeb.PingChannel, change the channel named “ping:*” to “ping”

In another thread, the author suggests pinning the version of Elixir and Phoenix so as to match the book. But I think it’s important that readers have confidence that they can immediately apply what they learn from this book in their own projects using the latest version of Phoenix.

I took the decision to add the “–no-live” flag when creating the Phoenix app in case having LiveView integrated made things more confusing. In previous versions of Phoenix, one had to explicitly add LiveView; now it comes as a default without the flag.

Most Liked

creminology

creminology

I think it would be great if you could persuade PragProg to let you publish a Github repository of the code; ideally the original code with the commits to make it compatible with Phoenix 1.6.x.

The link to the zipped code repository is on their book page so it’s not as if it’s hidden from non-purchasers. Perhaps they didn’t want to deal with readers posting issues directly to Github.

I do think the book needs some kind of statement or sidebar about why it still has value even in a world where everyone seems to be adopting LiveView. Even if LiveView is introduced later!

One key reason I picked up the book again, which I bought in September 2019, is that I noticed you were still engaging with readers on this forum. So I do appreciate your feedback.

sb8244

sb8244

Author of From Ruby to Elixir and Real-Time Phoenix

I appreciate this report, and it will definitely be addressed in the next update (although I’m not sure when that will be).

Pinning the version is great for people that just want to work through the content, because 99.8% of it hasn’t changed. But I do agree that using the latest version is generally “best” if the user can handle the warnings / upgrade path.

Few thoughts on differences that I know off the top:

  • PubSub 2.0 breaking changes regarding PubSub creation
  • Test warnings due to use ChannelCase instead of import ChannelCase
  • Generators have changed significantly as LiveView has progressed

I’d love to collect additional breaking changes that cause the book to not compile / work as expected.

creminology

creminology

Replying to myself, if there was an update to the book, I think it would be great if you could extend Part IV with guest-written chapters on how to connect it to other frontends such as Flutter, iOS and Javascript frameworks other than React.

For example, perhaps Paul Hollyer who maintains the elm-phoenix-websocket library, would be up for writing an Elm chapter. The fact that he recently released v4 was another reason I picked up your book again.

It’s not that these additional chapters would necessarily add knowledge on using Phoenix for real-time that isn’t already in your book, but they may introduce experiences and strategies more suited to their specific domains.

Anyway. Thanks again for the book.

Where Next?

Popular Pragmatic Bookshelf topics Top

belgoros
Following the steps described in Chapter 6 of the book, I’m stuck with running the migration as described on page 84: bundle exec sequel...
New
telemachus
Python Testing With Pytest - Chapter 2, warnings for “unregistered custom marks” While running the smoke tests in Chapter 2, I get these...
New
jesse050717
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
fynn
This is as much a suggestion as a question, as a note for others. Locally the SGP30 wasn’t available, so I ordered a SGP40. On page 53, ...
New
brunogirin
When installing Cards as an editable package, I get the following error: ERROR: File “setup.py” not found. Directory cannot be installe...
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
mert
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
Keton
When running the program in chapter 8, “Implementing Combat”, the printout Health before attack was never printed so I assumed something ...
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
davetron5000
Hello faithful readers! If you have tried to follow along in the book, you are asked to start up the dev environment via dx/build and ar...
New

Other popular topics Top

ohm
Which, if any, games do you play? On what platform? I just bought (and completed) Minecraft Dungeons for my Nintendo Switch. Other than ...
New
PragmaticBookshelf
A PragProg Hero’s Journey with Brian P. Hogan @bphogan Have you ever worried that your only legacy will be in the form of legacy...
New
siddhant3030
I’m thinking of buying a monitor that I can rotate to use as a vertical monitor? Also, I want to know if someone is using it for program...
New
PragmaticBookshelf
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
AstonJ
I’ve been hearing quite a lot of comments relating to the sound of a keyboard, with one of the most desirable of these called ‘thock’, he...
New
PragmaticBookshelf
Rust is an exciting new programming language combining the power of C with memory safety, fearless concurrency, and productivity boosters...
New
AstonJ
Just done a fresh install of macOS Big Sur and on installing Erlang I am getting: asdf install erlang 23.1.2 Configure failed. checking ...
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
Saw this on TikTok of all places! :lol: Anyone heard of them before? Lite:
New
First poster: bot
The overengineered Solution to my Pigeon Problem. TL;DR: I built a wifi-equipped water gun to shoot the pigeons on my balcony, controlle...
New

Sub Categories: