Show HN: LiveViewJS – TypeScript back end for LiveView Apps (Phoenix LiveView) (github.com)
Author here. I really love the programming paradigm behind by Phoenix LiveView applications and wanted to expand the ecosystem to include programmers like myself that love Typescript.
In summary, LiveViewJS reuses all the Phoenix client code and implemented a new backend in Typescript to handle client events and send back updates. Lots more detail and examples in the repo.
Would love any questions and/or feedback. Thanks!
47 comments
[ 3.2 ms ] story [ 88.0 ms ] thread> Think of it as the Node.js analog to Phoenix LiveView — all of the application logic (including rendering) runs on the server, and DOM updates are sent to the client in real-time.
I'll add that the API for implementing components in LiveViewJS follows the Phoenix API (mount => handleParams => handleEvent => render) rather than the React API.
It's definitely an interesting space to explore, I will take a look @ caldera, seems like an interesting project!
Live view works so well because of elixir and BEAM. The same model may not translate well to other languages depending on their concurrency and recovery pattern. There are also many optimizations in BEAM for keeping latency consistent over throughout alone which is important for live view applications.
I also wonder if it will be possible to have push only live view application. One of the reasons for this is you can use server events instead of sockets. It would be cool for building visualization or showing metrics from backend.
Awesome job all around. I love the examples folder.
That said, I think there are other server technologies to back LiveViewJS apps that may be able to scale out and perform just as well as BEAM including: Redis and DynamoDB. I plan to experiment with these in the near future.
Additionally, a big motivation for me was that I wanted to write apps in a language that I am very productive in (namely Typescript) which also has a large ecosystem and larger population of developers.
Lastly, in terms of other languages that I think could be well suited for this paradigm, Golang stands out (with channels and goroutines) but I haven't experimented with that yet.
This is extreme and maybe true. The best way to make TypeScript scale like BEAM might be to build a TypeScript -> Beam compiler. :D
I do like the idea of a Typescript to BEAM compiler but that is beyond my capabilities and interests. Maybe someone lurking here could do that?
Bringing a Redis cluster back up is either "start each node in exactly the right order", "wait 10+ minutes", or "establish quorum yourself". Ten minutes can be a really long time in production.
https://github.com/jfyne/live
I'll join your discord and we can chat more...
I think deno may work out of the box with --compat flag but i haven't tried it.
My project is https://diffhtml.org/ and I have started experimenting with middleware to bridge to server and client workers: https://github.com/tbranyen/diffhtml/pull/251. For the server worker, it uses a WebSocket to ferry the VDOM diff patches, custom events, and property access/function calls. A big goal is to allow synchronous "main thread" access from workers, including on the server-side. This would allow you to write your UI code as if you were a client side app. It does this the same way as partytown using a SharedArrayBuffer and Atomics. You can see demo source code here: https://gist.github.com/tbranyen/2f5be81cfb7b3aa1bb443c8ef13....
I've also toyed around with hot reloading components without the need for a pre-processor like Babel, and the results are hugely promising. Stateful live UI updates from saving a component file to seeing in the browser without all the fuss with complex build steps is liberating.
I'm probably a few months out from having a usable beta, but I'm going to follow your project closely. Thanks for sharing!
Nice work on diffhtml!
LiveView was invented not to have to deal with Javascript-powered SPA architectures and client-side coding in general, because JS is ass, and here's LiveViewJS to convert to Javascript a technology invented not to deal with Javascript.
Gary Bernhardt warned us, yet no one listened. shakes fist at cloud
https://www.destroyallsoftware.com/talks/the-birth-and-death...
> Ice-nine is an alternative structure of water that is solid at room temperature and acts as a seed crystal upon contact with ordinary liquid water, causing that liquid water to instantly transform into more ice-nine.
A substance called ice-9, with basically the same properties, makes a passing appearance in the visual novel Zero Escape: Nine Hours, Nine Persons, Nine Doors if you haven't heard of the book but remember the term from somewhere else.
Admittedly, that's where I first learned about it but that said, there is a real substance called Ice IX but it isn't as interesting
https://en.wikipedia.org/wiki/Ice_IX
Maybe instead of shaking your fist, you might just celebrate the fact that we live in amazing times where even JS programmers can enjoy the LiveView programming paradigm! :)
I used to agree with him but in 2022 we're still using yavascript and it's only getting better.
I have no doubt at some point we will get optional static types and even TypeScript will become obsolete like CoffeScript did.
I personally prefer JS over Elixir and having everything in one language also makes everything easier... maybe there is also a future to fuse some of these concepts into Svelte (I will have to experiment :D )
I want to contribute some sort of guide to the community for people coming from JS metaframeworks, rather than Rails/MVC frameworks, but I feel like I need to use Phoenix more first. I'm just about finished with Sophie and Bruce's book!
I wrote LiveViewJS while taking this course believe it or not.
Although, the safety of Typescript is the only thing that stops me from building my next hobbie/side-project with Elixir. After you get the benefits from the type system (specially in the TS ecosystem), it's hard to go back.
Looking forward to see where the project goes!
I believe you are referencing this line from the README? FWIW - they have a free "starter course" which includes that video. I started on the free course and upgraded because I got a ton of value out of it and they are a small company doing great work.
To be clear, LiveViewJS has no affiliation with Pragmatic Studio. I am just a fan. :)
> what would be the use for this
Ideally, to write LiveView applications in Typescript. :) This is early in development but as I mentioned above I think there are server technologies like DynamoDB and Redis that I plan to explore for scalable data stores.