axelson

axelson

Scenic Core Team

54) ElixirConf US 2018 – Closing Keynote – Chris McCord

ElixirConf US 2018 – Closing Keynote – Chris McCord (@chrismccord)

All talks thread:

Most Liked

grych

grych

Creator of Drab

This is true, actually Drab is quite mature, because it’s been born in the long discussions in this forum.

  • small reads and updates of DOM (Drab.Element, Drab.Query)
  • quick access to the browser-specific attributes, like a local timezone (Drab.Browser)
  • Drab.Modal, which is IMO a killer feature as it actually hold on processing and waits for the user input
  • Drab.Waiter, which does the same but more general, without a modal
  • and, last but not least, ability to calculate using browser (exec_js(socket, "2+2"))

So after reconsideration I am going to move Drab to the v1.0, as it is just a few steps ahead, and a lot of code for this is already done. I hate wasting good code. The project will be supported (bug fixes) as long as people are using it, but no new big features will be developed by now (sorry @OvermindDL1, no token via cookie, as I want to wait to see how Chris will cover this, but we may think about building our own transport as it would be easier since phx1.4).

Then I will take a break and will see what will born as a LiveView. If, as I assume, it will be a huge success, I will give up Drab.Live and Commanders and adopt rest of the Drab features to the LiveView, using its event handler API (phx-click attributes). Which accually I like more than mine, I probably overcomplicated stuff with Commanders, but have some concerns if it can cover some cases.

brightball

brightball

I really hope @chrismccord works with you on LiveView. You’ve definitely pioneered and popularized this entire concept within this community.

grych

grych

Creator of Drab

I don’t know if it is helpful, but this is how Drab does it. In compile time:

  • it has its own EEx engine
  • during compilation the Drab EEx, while handle_expr, it is checking if there are any assigns inside the expression
  • if there are assigns, it is injecting the special attribute (drab-ampere), to the parent tag; if there is no parent tag, it is surrounding the expression with the <span>
  • injecting the attribute also checks if the assign is in the tag body, or in the attribute
  • there is a special mark, <%/ %> which marks expressions which should not be ‘drabbed’
  • at the end, it collects all amperes with the corresponding assigns; this is how it knows where to change if you update the assign in a runtime
  • assigns are stored in the frontend, Drab injects javascripts like window.__drab.assigns.myassigns = <%= @myassign%> to the template

In a runtime:

  • you render the template as usual, with the controller
  • on connect, Drab gets the current assign values from the frontend and cache it in the genserver
  • on any assigns change (called poke), Drab re-renders the template on the backend; because it know exactly where in the template the assign you are changing is begin used, it gets the value of the tag body (or the attribute value) with Floki
  • then it sends the JS back to the browser - it is a simple update of the specific tags only
  • it also sends back the new assign value to the browser - this is important, because in case of disconnect the Drab genserver is killed

There are also corner cases, like a special treatment for @conn, or keeping the csrf token in case you update the whole form, or detecting which ampere to update in case they are nested.

All the above looks complicated, but this was the only what I could invent with the assumptions that:

  • you do not require many changes to the existing phoenix project: in this case the only change is the extension from *.eex to *drab
  • it must be beginner friendly (to convince beginners who are scared of Ajax and JS)
  • it must work as expected, be intuitive (this is why assign values must survive disconnection)
  • all must be archived with external library only, without any changes to Phoenix (as they are not very welcomed)
AstonJ

AstonJ

Awesome keynote Chris!

Loved hearing about LiveView… and this bit made the hairs on the back of my neck stand up :003:

“Challenge the status quo of what is possible” :049:

“We have this platform that can advance the state of the art” :049:

“The future is ours to build” :049:

tme_317

tme_317

Although we’ve seen similar patterns before (i.e. drab) LiveView still totally blew me away and I’ve rewatched the video 3 times now. Now tomorrow morning I get to write tons of React form validation code and repeating the same/similar code in my changeset validations on the server and dealing with all the plumbing… while thinking how much easier it would be with LiveView with no perceptible performance degradation.

The way it was presented it seems like you could make LiveView “components” (stateful and stateless (not needing a GenServer?)) and hook them together like a React component tree. It seems weird to say but maybe we could have “JSX-like” syntax inside the EEx LiveView components which could call other LiveView module’s render functions with props (assigns) and children. All the data would be accessible server-side so less need all the JSON/GQL requests. It seems like that should work… and it could be the right choice for many (not all of course) project types.

Unbelievably incredible job @chrismccord just can’t wait until it is released for experimentation!!

Where Next?

Popular in Talks Top

axelson
ElixirConf 2017 - Elixir as a first language - Alexis Huefner What would it be like to use Elixir as your fi...
New
axelson
by @chrismccord My summary: Chris gives an update and copious demos of Phoenix LiveView which is now released on hex.pm. Demos on: ...
New
CodeSync
Code Sync: Writing much better tests in Elixir by Xochitl Pérez | Code BEAM Lite Mexico 2023 Comments welcome! View the <span class="has...
New
axelson
ElixirConf 2017 - Streaming Video with Elixir - @johnwahba Running a video stream is challenging. You can’t ...
New
axelson
ElixirConf 2017 - Day 2 Morning Keynote - @josevalim All talks are available in the Elixir Conf 2017 Talks ...
New
axelson
ElixirConf US 2018 – Behavior Trees and Battleship: Tapping into the Power of Advanced Data Structures – Jeff Schomay I ...
New
axelson
ElixirConf US 2018 – Take Your Time – Ben Marx (@bgmarx) OTP20 officially introduced dirty schedulers. In this talk, we’...
New
axelson
Consistent, Distributed Elixir - @keathley Elixir and Erlang provide powerful mechanisms for building systems that are alw...
New
JuanjoA
Hi, I don’t know if I have the post in the right place. I put here in case you might be interested, I am not the author, I just found it...
New
New

Other popular topics Top

aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
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
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New

We're in Beta

About us Mission Statement