
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










Modern Front-End Development for Rails - application does not start after run bin/setup (page xviii)
Other popular topics










Latest in PragProg
Latest (all)
Categories:
Popular Portals
- /elixir
- /opensuse
- /rust
- /kotlin
- /ruby
- /erlang
- /python
- /clojure
- /react
- /quarkus
- /go
- /vapor
- /react-native
- /v
- /wasm
- /django
- /security
- /nodejs
- /centos
- /rails
- /haskell
- /fable
- /gleam
- /js
- /swift
- /deno
- /tailwind
- /assemblyscript
- /laravel
- /symfony
- /phoenix
- /crystal
- /typescript
- /debian
- /adonisjs
- /julia
- /arch-linux
- /svelte
- /spring
- /c-plus-plus
- /preact
- /flutter
- /actix
- /java
- /angular
- /ocaml
- /zig
- /kubuntu
- /scala
- /zotonic
- /vim
- /rocky
- /lisp
- /html
- /keyboards
- /emacs
- /nim
- /vuejs
- /nerves
- /elm