brainlid

brainlid

Blog Post: 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!

Where Next?

Popular in Blog Posts Top

mudasobwa
Just blogged on the general approach to creating easily extendable applications with plugin support.
New
luckywatcher
Hey all! I just started a blog focused on web development in Elixir. I wrote my first article and thought I’d post it here for the whole...
New
brainlid
There is a new community resource available on writing “Safe Ecto Migrations”. When we get a migration wrong, it can lock up your product...
New
Paradox
Testing is an important part of any modern piece of software. But writing tests can quickly become an exercise in frustration, with tons ...
New
Alex66
I ran Symphony through Giulia, here’s the AST analysis. Yesterday, OpenAI open-sourced Symphony — an autonomous agent orchestration fra...
New
fredwu
Hi folks, I wrote a blog post the other day on how I built my MVP in 3 months whilst having a day job, using Elixir/Phoenix/LiveView. Th...
New
rrrene
In this series, we take a look at the different ways to organize, structure and execute a good “flow” in our Elixir programs. The latest...
New
AstonJ
Update: How to use the blogs section You can post in one of the Official Blog Posts threads (like this one), or, via Devtalk and a new t...
New
axelson
I describe how we use Hot Reloading with Webpack to develop faster and show how to integrate Webpack 5, webpack-dev-server, and Phoenix f...
New
Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 126479 1222
New

Other popular topics Top

marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 53690 245
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
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
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
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
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New

We're in Beta

About us Mission Statement