
Chrichton
Programming Phoenix LiveView: B3.0 (page 27)
I tried to do the exercise for the basic LiveView “game”.
One part is:
Show a restart message and button when the user wins. Hint: you might want to check out the live_patch/28 function to help you build that button
Several things were not clear to me:
- Should the success message and the Restart-Button be displayed in a new LiveView (CorrectLiveVive) or should I use the existing LiveView (WrongLiveView)?
I decided to use the existing LiveView.
As I had to conditionally render the view for the success-case and the wrong-case,
I added another state (answer_guessed Boolean) to the socket.
This allowed me to use this state to conditionally include the “live_patch”-method inside the render-function for the success case.
I then realized, I had to implement the “handle_params”-method correctly.
See: pento/wrong_live.ex at master · Chrichton/pento · GitHub
I am asking: Is there an easier way to solve this exercise?
Thank you for your reply, Heiko
Popular Prag Prog topics










Other popular topics










Latest in PragProg
Latest (all)
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /ash
- /centos
- /php
- /deepseek
- /zig
- /scala
- /html
- /debian
- /nixos
- /lisp
- /agda
- /sublime-text
- /textmate
- /react-native
- /kubuntu
- /arch-linux
- /revery
- /ubuntu
- /manjaro
- /spring
- /django
- /diversity
- /nodejs
- /lua
- /slackware
- /julia
- /c
- /neovim