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)

Where Next?

Popular in Talks Top

axelson
Today’s talk is another one from Toyota Connected ElixirConf 2017 - Elixir with Kafka - Mathew Gardner Elix...
New
axelson
Okay, after many days here is the final post on the Elixir Conf videos. Since there are so many lighting talks I felt that it is better t...
New
axelson
Almost done with posting the Elixir Conf talks! ElixirConf 2017 - Realtime Vehicle Tracking with Elixir and Phoenix - @st23am ...
New
axelson
ElixirConf 2018 – Day 2 Opening Keynote – Justin Schneck (@mobileoverlord) All talks thread:
New
Lawrence_elixir
@voltone - Security advocate, BEAM enthusiast Learn you some ‘ssl’ for much security! Talk in three words: TLS, security, troubleshooti...
New
brightball
Since the comments are turned off on the YouTube videos, I’m going to post on talk per day on here for viewing and discussion…starting wi...
New
ElixirConf
ElixirConf: ElixirConf 2022 - Brian Cardarella - What is LiveView Native? Comments welcome! View the <span class="hashtag-icon-placehold...
New
AstonJ
#Day 1 ElixirConf 2017 - Day 1 Keynote - Justin Schneck (Discussion thread) ElixirConf 2017 - My Journey from Go to Elixir - Veronica L...
New
axelson
ElixirConf US 2018 – Building Video Chat with Elixir &amp; Phoenix – Anil Wadghule (@anildigital) In this t...
New
rodrigues
Day 1 Keynote about Lumen - An alternative BEAM implementation, designed for WebAssembly by @rcm765 @KronicDeth @bitwalker...
New

Other popular topics Top

danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29603 241
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
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
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
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
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement