redrapids

redrapids

Author of Adopting Elixir

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?

Showing Posts 1 to 10

romenigld

romenigld

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

redrapids

redrapids OP

Author of Adopting Elixir

Does anyone have any comments about the teaching approach to LiveView specifically, and Elixir in general? Basically, my approach is to get students to reducers, and using them in the context of an API. Once I can get them there, it gets easier.

Comments?

sb8244

sb8244

Author of Real-Time Phoenix

Are reducers the functionally pure way to interact with your data structure (like a brick or board)? I’m only on the second video but I plan on watching these soon. I’m happy to give more specific feedback once I’m the whole way through it.

If yes, I think that’s pretty sound. It’s much easier to think about the problem in bite size chunks rather than tackling it all at once. I think that learning to decompose the problem (what are the reducers and functional core of my app going to be?) is one of the most important—but also subtly difficult—parts of learning to write good applications.

redrapids

redrapids OP

Author of Adopting Elixir

yep… it’s a little cloudy in Elixir because Enum.reduce takes an accumulator as the SECOND argument, but we tend to build modules with the target item as the FIRST argument. So… we’re looking at something like:

brick
|> rotate(90)
|> right
|> down

to move the conceptual model of the brick. At another level, we use a points module. Not a struct, but applies to functions we’re using to manipulate a list of points:

def rotate(points, 90) do
  points 
  |> transform #{x, y} to {y, x}
  |> mirror
end
def rotate(points, 0), do: points
def rotate(points, degrees) do
  rotate(
    rotate(points, 90), 
    degrees - 90
  )
end

rotate on points is a reducer.
On brick: rotate, right, left, down are all reducers.

-bt

AstonJ

AstonJ

This looks really nice and was exactly the sort of thing I was hoping you’d do Bruce!

I think I am going to go through it after the Phoenix book :003:

Just a couple of quick questions…

  • Is the $10 for the complete course (or is it $10 per video)
  • Is there a time limit on that offer? (Should we buy now or is it ok to wait a little while?)
  • Is there a time limit on access to the course once you’ve bought it?

Finally, do you want us to move this thread to the #courses section? People (especially newcomers) are more likely to browse those sections. If so let me know and we’ll make some edits and move it there :023:

redrapids

redrapids OP

Author of Adopting Elixir

$10 for all of them :slight_smile:

Basically, I had to make them for the mentoring program as there’s one of me and four groups, and someone came up with the idea of selling them to support the program.

-bt

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.

ranska

ranska

I’m a newbie in this language. And I think it’s a good starter.
I’m on ep 3 for now. :slight_smile:

Sanjibukai

Sanjibukai

Do you mean by “reducers” functions that takes and returns Ecto.Changesets and Plug.Conns (and the like) that typically always return the same data structure as its first parameter?

I mean this applies if I consider a reducers as functions that take two parameters and apply (or use) the second parameter in order to return a transformed version (or not) of the first parameter (like Redux in front-ends with DOM States and events..)

As an Elixir beginner (coming from Ruby), it took me some efforts to grasp the fact that those kind of functions works well with data structure that have both inputs and outputs (like Plugs.Conn, or Ecto.Changeset) and it seems that this is a big “pattern” in FP and used almost everywhere.

So, I think (at least for me) that this is indeed something really important to teach/learn particularly for custom data structures (in contrast to Plugs, and Changesets, where we simply use them rather to design them..)

So I hope I will learn a lot from these videos..

Edit: I just realized that you are Bruce Tate.. Thank you for the videos BTW..

Sanjibukai

Sanjibukai

Hello @redrapids,
To answer to the question of the topic, now I took the course..
Well.. I’m kinda left hungry for more, particularly regarding the “LiveView” parts..
I mean, the course name is “Phoenix Liveview Tetris in Elixir” but it happens to me as if it was “Tetris in Elixir”.

I learn more about Liveview in this video of you https://www.youtube.com/watch?v=-wzabRyc-0M (saw on the forum) and even more in this one from Chris McCord https://www.youtube.com/watch?v=8xJzHq8ru0M

For example, I expected to see more about the mechanisms that allow to start from the custom attribute written in the HTML part of Phoenix all the way down to the Elixir part where the events are handled.

Also a better explanation of the whole flow (including the JS parts) and all the life cycles (from the first HTTP request, to the mount of the WebSocket, and the rest) would be really appreciated.

Even if there is no need to write JS with LiveView, there is still some JS involved, it would have been also great if those default JS parts included by Phoenix were a little explained particularly how LiveView is different from regular WebSockets.

I also expected to learn more about the events and the whole process (including morphdom) as it’s a little explained by Chris on his video.

In that video above (where LiveView was quite new at that moment) you explained, that many events are handled by Phoenix but it’s even easier to add custom events.. So I would have expected this part to be present in the course too.

But maybe it’s me and there is no need to talk more about LiveView, I don’t know…

Anyway, it was not that expensive at least, so no regret for me…

And by the way, many thanks for all the effort put into all these learning resources..

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 92995 915
New
caslu
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
GES233
I’m posting this in response to Jose’s recent tweet (Cr. link) : People are sleeping on Elixir for a coding harness: Hot-code swappi...
New
_mfierro
Hello, I wrote Stop My Hand, a Scattergories-like web application using Phoenix/LiveView as my learning project for Elixir (after readin...
New
nseaSeb
AcmeScript — Writing JS hooks as if I were still using Elixir I’ve been having fun building a little something over the last few days: Ac...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews