redrapids

redrapids

Author of Adopting Elixir

Has anyone seen Building Tetris on Elixir/LiveView?

Groxio is building a series targeted to beginner and intermediate Elixir developers at Quadblock- Elixir/LiveView videos. The first seven are free, and the rest will go for 10 bucks. The proceeds will go to fund coding diversity mentoring programs. I would love comments on the approaches, as I’ll use the same approach in the prag book.

In general, it’s the course my mentees to through (or the first part). I seem to have success teaching these concepts:

  • Understand pattern matching first
  • Organize modules into like concepts around DATA
  • Organize code around the data concepts, with as many reducers over that type as possible
  • Write tests as pipelines

Then, the LiveView discussion becomes easy:

  • In LiveView, build a static screen first, with hardcoded data in mount
  • Change the hardcoded data as your functions later will to flesh out your render
  • If needed, extract render-text text into views

And next:

  • Replace hardcoded mount with dynamic content (your true model)
  • Change the data with handle_event and handle_info
  • Keep the handle-callbacks skinny. If necessary have adapter functions in the Live module

Finally:

  • Optimize the liveview difs, and tighten them up
  • Extract common components
  • Implement data rehydration concerns
  • Implement pubsub concerns

Does the approach seem sound?

Most Liked

redrapids

redrapids

Author of Adopting Elixir

Thanks for the insight.

I would like to offer a counter perspective. I could have built an app in LiveView that built all of this code, or most of it, into the view. Some of the examples are built in this way. Doing so would have given the appearance of being a video about LiveView. That approach would have been misguided.

Coding a nontrivial LiveView or OTP will be like what I presented most of the time. If you build something nontrivial, the hard part won’t be the LiveView. It will be the pure core of what your building.

Layering your code into pure elixir for consumption in LiveView IS the problem. It’s the separation of boundary and pure code, the use of reducers, and the like that separate a good codebase from a poor one.

It’s very much like designing elixir systems for OTP. It’s not a book about OTP. It’s a book about building things that uses OTP, and it should be.

romenigld

romenigld

I like the game and saw yesterday a little.
I will buy this month for sure it’s a nice price.

crisefd

crisefd

Just finished the course, easy to follow and I learned a bunch while building the app. Highly recommended if you are already mid-level-ish in the language. And it’s a good introduction to LiveView.

Where Next?

Popular in Discussions Top

vans163
So useless benchmarks aside, Its possible to write a webserver that can serve 300k requests per second (perhaps more with optimizations)....
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
thojanssens1
It would be nice to be able to define a redirect from one route to another from the router.ex file. E.g.: redirect "/", UserController, ...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
shishini
I think this twitter post and youtube video didn’t get as much attention as I hoped I am still new to Elixir, so can’t really judge ...
New
PragTob
Hey everyone, this has been on my mind for some time and I’d love your input on it! TLDR: I feel like maps are superioer for storing and...
New
joeerl
I’m playing with Elixir - It’s fun. I think @rvirding does give Elixir courses these days. Re: files and database - when I given Erlang ...
New
scouten
I’m looking for a host for the server part of a small (personal) side project that I’m working on. It’s currently written in Node.js and ...
New
fireproofsocks
This is more of a general question, but I’m wondering how other people in the community think about the pattern matching in function sign...
New

Other popular topics Top

Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54120 245
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement