brainlid

brainlid

Star-Crossed LiveView Processes

Elixir has many powerful runtime features: processes, monitors, links, supervisors, and more. Sometimes, the hardest part is knowing which building blocks are the best ones for what we want to do. In this post I explore linking processes, trapping exits and running an async Task from a LiveView to solve a different kind of problem.

There’s been a lot written about running an async Task from a LiveView, but I wanted to build a ChatGPT-style UI where the data flows in, not just the final computed result.

In fact, I only care about the series of messages sent as side effects from the running Task. This difference changes how we approach the problem. In the post we see ho process linking is like Romeo & Juliette. When Juliette dies, it causes Romeo to die as well, the two are linked. This is the same for linked processes. But if we trap exits, our LiveView will be “notified” of a Task processes’ death without being killed. Turns out it’s both really simple and really powerful!
I :heart: the BEAM!

Popular Backend topics Top

Scorpil
I dabbled in Phoenix for a while now, but never really got my hands dirty with it right up until now. Apart from the whole framework bein...
New
New
CommunityNews
Is Zig the Long Awaited C Replacement. Comparison with previous C contenders such as C++, D, Java, C#, Go, Rust and Swift https://erik...
New
First poster: bot
We all know how to teach recursion. We’ve done it for decades. We pick some honored, time-tested examples—Fibonacci numbers and factorial...
New
First poster: bot
In a previous post we talked about implementing a simple video chat with WebRTC and Elixir. This update will touch on some of the API cha...
New
Rainer
Just wrote a short post, more a memo to myself, but maybe someone find it useful :stuck_out_tongue: https://dwarfte.ch/2021/02/03/giving...
New
AstonJ
If you’re interested in Rust this is worth a read :smiley: Technology from the past come to save the future from itself Hi I have be...
New
First poster: malloryerik
Everyone outside of tech has heard of JavaScript, Java, Python, Ruby and even .Net, but few if any have heard of F#. However, F# may be o...
New
wolf4earth
Charles Max Wood takes the lead this week. He and Adi Iyengar discuss what Top End Devs are and what people should be doing to become Top...
New
First poster: AstonJ
Ruby’s Struct is one of several powerful core classes which is often overlooked and under utilized compared to the more popular Hash clas...
New

Other popular topics Top

siddhant3030
I’m thinking of buying a monitor that I can rotate to use as a vertical monitor? Also, I want to know if someone is using it for program...
New
AstonJ
Curious to know which languages and frameworks you’re all thinking about learning next :upside_down_face: Perhaps if there’s enough peop...
New
Rainer
My first contact with Erlang was about 2 years ago when I used RabbitMQ, which is written in Erlang, for my job. This made me curious and...
New
AstonJ
I ended up cancelling my Moonlander order as I think it’s just going to be a bit too bulky for me. I think the Planck and the Preonic (o...
New
AstonJ
If you are experiencing Rails console using 100% CPU on your dev machine, then updating your development and test gems might fix the issu...
New
wmnnd
Here’s the story how one of the world’s first production deployments of LiveView came to be - and how trying to improve it almost caused ...
New
AstonJ
If you get Can't find emacs in your PATH when trying to install Doom Emacs on your Mac you… just… need to install Emacs first! :lol: bre...
New
AstonJ
If you want a quick and easy way to block any website on your Mac using Little Snitch simply… File > New Rule: And select Deny, O...
New
New
sir.laksmana_wenk
I’m able to do the “artistic” part of game-development; character designing/modeling, music, environment modeling, etc. However, I don’t...
New