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!

Where Next?

Popular Backend topics Top

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
Such inflammatory, much wow. Unfortunately, Haskell itself agrees. Some languages naturally lend themselves towards adoption. Some don’t...
New
First poster: AstonJ
Ten years without Elixir. I never got into Elixir, largely because it looked like Ruby. I was a Rubyist for a good while, spent time and...
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
First poster: bot
What’s Next for Teal, the typed dialect of Lua - FOSDEM 2021. This is my talk about the latest updates on the Teal programming language,...
New
brainlid
We take a deeper dive with Nathan Long into IOLists in Elixir. We cover what they are, how they work, the power they have when concatenat...
New
AstonJ
This was posted on the Elixir Forum and thought it was worth sharing here! I love how the excitement of the author shines through and I ...
New
brainlid
Jason Stiebs shows a couple ways for a LiveView to make it easy for users to click and copy an important value to their clipboard. He sho...
New
fullstackplus
The Ruby ecosystem is rich with tools that make us developers more productive at what we do. Both Rails and Sinatra have been used to bui...
New

Other popular topics Top

Devtalk
Reading something? Working on something? Planning something? Changing jobs even!? If you’re up for sharing, please let us know what you’...
1033 17470 383
New
ohm
Which, if any, games do you play? On what platform? I just bought (and completed) Minecraft Dungeons for my Nintendo Switch. Other than ...
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
AstonJ
I’ve been hearing quite a lot of comments relating to the sound of a keyboard, with one of the most desirable of these called ‘thock’, he...
New
PragmaticBookshelf
“Finding the Boundaries” Hero’s Journey with Noel Rappin @noelrappin Even when you’re ultimately right about what the future ho...
New
AstonJ
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first: asdf plugin-upd...
New
AstonJ
Seems like a lot of people caught it - just wondered whether any of you did? As far as I know I didn’t, but it wouldn’t surprise me if I...
New
AstonJ
Saw this on TikTok of all places! :lol: Anyone heard of them before? Lite:
New
First poster: joeb
The File System Access API with Origin Private File System. WebKit supports new API that makes it possible for web apps to create, open,...
New
New