grych

grych

Creator of Drab

Drut: an idea for the low-level foundation for LiveView, Texas or Drab - like libraries

Hi all,
based on this, and discussions here before (like @OvermindDL1’s idea to use cookie to transfer the token), there is an idea to create a low level library which may be a foundation for Drab and other guys.

It should not be based on Phoenix, but rather on Plug and/or Raxx (extendible for the future), so you can use it in other frameworks as well. It should have the own transports, websocket for the beginning, but extendible as well.

The API I am thinking of is rather straighforward, as in fact Drab is build over few functions:

  • exec_js - runs given javascript in the browsers; should be both sync and async
  • broadcast_js - runs given javascript in all the browsers listening on some topic; only async
  • exec_elixir - runs Elixir function from the frontend; sync and async (TBD)

exec_elixir may be replaced with something more message-like, rather than running the function with its name (just like @chrismccord did in the LiveView demo), TBD. Security: TBD.

Everything on the upper level may operate on that. We can move Drab to use Drut in Drab 2.0 (it will require changes in installation process, etc). Some parts of Drab (Drab.Element, Drab.Browser, even Drab.Query) might be pulled out of Phoenix, but some must stay (Drab.Live strongly depends on Phoenix engine). Things like Commanders would stay on the Drab level.

WDYT?

Most Liked

chrismccord

chrismccord

Creator of Phoenix

This sounds like a great effort! As Drab is approaching 1.0 it makes sense to start looking at the abstractions and building blocks that could be extracted. However, I caution working to strip things down too early. For the LiveView case, it’s definitely too early for us to start drawing the abstraction lines, since a lot of those abstractions we are still working to fully figure out :slight_smile: Extraction is good where it makes sense, but going too early or too granular can slow you down or be a big maintenance burden, so I wouldn’t be too quick start stripping Drab down prior to 1.0. As things progress on the LiveView side, I’ll be happy to revisit common abstractions, but it’s too early on my side at the moment :heart:

grych

grych

Creator of Drab

Well, this would be more the side project, rather than stripping down Drab, but they should meet at the some point in the future. What I want to do is a kind of Plug for a server-side frontend processing, which anyone can use to do something like Drab, on any Plug or Raxx based framework.

I realize this is a big effort, as there are many things which Phoenix does for free, like PubSub. But wait, we can use PubSub as it is already extracted from Pheonix :slight_smile:

The future of Drab itself is still unchanged, I will release 1.0 soon.

Things like Drab.Live, LiveView or Texas are Phoenix-based and obviously need to stay in the Phoenix world.

grych

grych

Creator of Drab

True, you don’t need Drut for Texas, as Channels are enough to push the changes back to the client. And because how it is done (operating over the template), Texas (and LiveView, and Drab.Live) with stay in the Phoenix world, no doubt.

This proposition is way more low-level, and thats why I wrote before started writhing. Maybe it is too early for such project? Maybe it is too much to re-write the great Phoenix Channels? Maybe it is too much to give developers exec_js instead of traditional websocket messaging? (did I just call websocket messaging traditional?)

Yes, Drab.Live only sends the small patches, but it is not doing the diff, but identifies where to change the page by marks which are done during the compilation process. The idea of diffing on the server is a way better I believe, and do not need a special engine. I just didn’t think about it, as Drab.Live evolved in time (for example, at the first step, it did not re-render the whole template, but rather executed small chunks of AST stored during the compilation).

Anyway, under the hood, Drab.Live sends the patches using exec_js. This is the part I want to isolate.

Absolutely true. But now, when I am reaching to graal of 1.0, it is a time to think about the future, this is why this post exist :slight_smile:

I imagine one could write a framework (something like what @raza described above), based on Drut, but with the different approach to communicate back to the browser - from “sending messages to the browser” to “executing code in the browser”.

Where Next?

Popular in Discussions Top

pillaiindu
In django there is a cache framework backed by memcached. Rails also puts a lot of emphasis on caching, and even the idea of russian-doll...
New
ricklove
I was just introduced to Elixir and Phoenix. I was told about the 2 million websocket test that was done 2 years ago. From my research, t...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39297 209
New
IVR
Hi all, I’ve seen a number of related threads in the past, but I’d still be very curious to hear an up-to-date opinion on this topic. I...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
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
AstonJ
I’ve just started the Phoenix part of the utterly brilliant online course by @pragdave. On generating the Phoenix app he uses the --no-ec...
New
chulkilee
Here are the list of HTTP client libraries/wrappers, and some thoughts on HTTP client in general. I’d like to hear from others how they w...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New

Other popular topics Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 42920 311
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...
274 41539 114
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43622 214
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
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
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36128 110
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement