CodeSync

CodeSync

Keynote: The Road To LiveView 1.0 by Chris McCord | ElixirConf EU 2023

Code Sync: Keynote: The Road To LiveView 1.0 by Chris McCord | ElixirConf EU 2023

Comments welcome! View the #code-sync and #elixirconf-eu tags for more Code Sync and ElixirConf EU talks!

Most Liked

chrismccord

chrismccord

Creator of Phoenix

When it’s ready :slight_smile: I gave our rundown of what we want to tackle for 1.0 in the talk, so follow the issues tracker to stay up to date. Now would be a great time to jump in!

AlchemistCamp

AlchemistCamp

This was my favorite Phoenix talk in a long time. During the last 1/3 of the talk, it felt almost like Chris had seen my code and built one solution after another for each headache I’ve encountered with LiveView the past several weeks!

Is there a link anywhere to the form demo repo?

fceruti

fceruti

I just spent a bunch of time going back and forward watching the video trying to implement the nested forms thing, and I got stuck trying to solve some issues. This post is about my findings.

Check out the video, it’s just ~15 sec. There are two bugs:

  1. After the first click “Add status” (add row), the checkbox stays selected, so when we “Add a role” (column), both a row and a column are added since both were checked. This is actually quite natural behavior, why would phoenix send updates on a static element? Actually I’m quite baffled it even worked in the demo at all.

The “Add Status” btn is similar to lines 45-48

  1. When I deleted row indexed 1, phoenix re indexed all the rows down, giving me a new indexed 1 checkbox and for some reason proceded to check this new index 1 checkbox (the button is similar to lines 36-39 in the picture). Then when I click to delete row 0, both row 0 & 1 are deleted. I’m not sure if this is a browser thing (tested on firefox & safari), a phoenix js thing or a morph dom thing.

What I do know now, is that all this bugs are solved IF… drum rolls please

IDs. Maybe some other attribute will work to, but ids are fine. We need something that triggers an update when we need a fresh new element, that includes a marker that helps whoever is confusing these elements.

For the elements outside inputs_for (add rows & cols), I’m using this:

n_rows = Phoenix.HTML.Form.inputs_for(form, :field_name) |> length()
...

~H""" 
<input [..] id={"add-row-#{@n_rows}"} />
"""

For the inside ones, it’s simpler. LiveView’s inputs_for (different from the Phoenix.HTML.Form one), adds a very self explanatory field _persistent_id to every nested form, which can be accessed like this:

<.inputs_for :let={f_status} field={@statuses_field}>
   <input type="checkbox" [...] id={"row-delete-#{f_status.id}"} />
</.inputs_for>

So, how is your weekend going? :stuck_out_tongue:

olivermt

olivermt

He says in the talk that he will :stuck_out_tongue:

chrismccord

chrismccord

Creator of Phoenix

yes an no. What you get currently optimistic UI wise is js commands and phx-disable-with, which allow you to provide immediate feedback when the user creates and deletes todos, but in a limited capacity. For example, check out the TodoTrek demo where I delete a todo, and it fades out immediately for 200-300ms, which would mask day to day latency. phx-disable-width also allows you to swap the content of a button to show loading states. You can also use JS.show|hide|toggle do to react-style loading placeholders. So you can do a reasonable amount of instant feedback on the client today, but it will be limited. For example, what you can’t do is dynamically render some server template on the client to for example make the todo look as if it’s inserted when it hasn’t yet made the round trip.

Where Next?

Popular in Talks Top

axelson
ElixirConf 2018 – Day 2 Opening Keynote – Justin Schneck (@mobileoverlord) All talks thread:
New
axelson
Here’s the last ElixirConf 2017 video of day one! ElixirConf 2017 - Scaling up Elixir at TpT - by @shanti I...
New
zporter
ElixirConf US 2018 – Breaking Down the User Monolith – Zach Porter Coming from Ruby on Rails, the convention is to have a...
New
axelson
ElixirConf US 2018 – You Can Never Debug the Code You Run, But You Can View the Code the Debugger is Running – Luke Imhoff (@KronicDeth) ...
New
axelson
ElixirConf US 2018 – Simple is Beautiful: Building an SLA Monitoring Tool Using Elixir/OTP at PagerDuty – Aish Dahal Sta...
New
axelson
Hey everyone! I hope everyone enjoyed ElixirConf! I know that I did. In order to facilitate and continue the discussion (especially since...
New
axelson
ElixirConf 2017 - Phoenix after 100000 lines - Renan Ranelli Given phoenix’s rise in popularity, the interne...
New
CodeSync
Code Sync: Keynote: The Road To LiveView 1.0 by Chris McCord | ElixirConf EU 2023 Comments welcome! View the #code-sync and #elixirconf-...
New
axelson
ElixirConf 2017 - Elixir Power Tracing - Gabi Zuniga Tracing is a technique for tracking events during a pro...
New
ElixirConf
ElixirConf: ElixirConf 2023 - German Velasco - Using DDD concepts to create better Phoenix Contexts Comments welcome! View the <span cla...
New

Other popular topics Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
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
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

We're in Beta

About us Mission Statement