akin

akin

Lissome: Phoenix LiveView integration with Gleam's Lustre framework

Hey everyone,

Recently, I’ve been working on a project that uses LiveView for most of the UI, but for some parts with very complex client state, it leverages Gleam’s Lustre framework.

If you’re not familiar with it, Lustre is a Gleam frontend framework that implements the Elm architecture and takes advantage of Gleam’s ability to compile to JS for building highly interactive UIs.

I wrote a few simple helpers and components to make integration easier and improve DX. They allow Lustre to be rendered anywhere inside HEEX and communicate with LiveView from Gleam via the WebSocket connection. It’s similar to LiveSvelte or other JS integrations, but with Gleam and Lustre. It also supports server-side rendering.

Would you be interested if I release this as an open source library (lissome)? I Just want to collect feedback before start extracting the code into a library.

Most Liked

akin

akin

Hey all! Just released the library, it’s still extremely early stage and a lot of work to do, but here is the repo and the hex package.

https://github.com/selenil/lissome/

I’ll be sharing here some new features as I add them.

13
Post #6
hayleigh

hayleigh

Wow what a cool project!

I see you’re using Lustre in its typical “SPA” mode:

pub fn main() {
  let json = get_element_by_id("ls-model")
  let flags = parse_flags(json)

  let app = lustre.simple(init, update, view)
  let assert Ok(_) = lustre.start(app, "#app", flags)

  Nil
}

and decoding flags and state like you would for traditional ssr/prerendering purposes.

You might also want to dig into Lustre’s component system: because these are built on native Web Components and you’d be able to communicate directly with a LiveView app through attributes and events like any other HTML element :slight_smile:

akin

akin

Release 0.3.1

Hey, everyone! This release brings new features and a refactor to the approach taken by the library for doing the integration between Lustre and LiveView.

The highlights are:

  • All the setup and Gleam integration with Mix has been completely changed in favor of a more solid and flexible approach. Details in the README.
  • Helpers for communicating with LiveView. Now Lissome includes its own Gleam package that you can add to your Gleam project as a path dependency. It contains various helpers, among them are function to interop with Phoenix LiveView using the Lustre’s effects system.
  • A live reloader that watches for changes in your Gleam files and recompiles them.
  • Helpers to work with Gleam types and their Erlang representation in Elixir.

Next step will be support for lustre.component component and Lustre’s server components.

Where Next?

Popular in Discussions Top

sashaafm
Piggy backing a bit on @dvcrn topic BEAM optimization for functions with static return type?, I’ve been trying to understand in a deeper ...
New
mbenatti
Following https://github.com/tbrand/which_is_the_fastest |> https://raw.githubusercontent.com/tbrand/which_is_the_fastest/master/imgs...
New
AlexMcConnell
The reason that Rails is as popular as it is is because it’s very easy for relatively inexperienced developers to get a lot of work done....
588 19652 166
New
ben-pr-p
In general I’ve been sticking to this community style guide GitHub - christopheradams/elixir_style_guide: A community driven style guide ...
New
wmnnd
The Go vs Elixir thread got me thinking: Would it be too hard to implement a simple mechanism for creating Go-style static app binaries f...
New
tmbb
This is a post to discuss the new Phoenix LiveView functionality. From Chris’s talk, it appears that they generate all HTML on the serve...
342 18243 126
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 39467 209
New
opsb
We’re considering our architecture from a viewpoint of scaling our traffic heavily over the next 6 months. Our current deployment is runn...
New
RudManusachi
What configs will make sense to put to runtime.exs? – A bit of how I configure apps: I have generic configs in config/config.exs, dev...
New
mmmrrr
Just saw that dhh announced https://hotwire.dev/ Is it just me or is this essentially live view? :smiley: Although I like the “iFrame-e...
New

Other popular topics Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
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 43757 214
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement