⚠️ This post links to an external website. ⚠️
The three great virtues of a programmer are laziness, impatience, and hubris. I lean toward laziness more than the other two, often thinking, “There’s got to be an easier way.” A recent example of this was when I was experimenting with streaming LLM output in LiveView. While researching, I found that the most popular article on the topic, Streaming ChatGPT Responses With Phoenix LiveView by Sean Moriarity, to be quite complex. I knew there had to be a simpler solution; that’s when I stumbled across LiveView’s asynchronous functions:
assign_async/4,stream_async/4,start_async/4, andhandle_async/3.These functions leverage Elixir’s lightweight processes to perform work off the main LiveView process. When the work is completed, your application can deal with the results without disrupting your user’s experience.
continue reading on samuelmullen.com
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.