Liveview framework1/16/2024 ![]() Here we build a simple thermostat component: defmodule MyAppWeb.ThermostatLive do Let's take a quick look at an example, take from the LiveView documentation, but simplified for demonstration purposes. There is of course some JavaScript on the client-side which maintains the websocket connection and manages the changes, but it's all built-in to the framework, and doesn't require you, the developer, to write a single line of JavaScript. The magic happens behind the scenes with a persistent websocket connection between the client and server. When the client state changes, the HTML template is re-rendered and anything that's changed is sent out to the client in small, compact diffs. LiveView uses simple declarative HTML rendering based on the current server state. Though the exact details vary a bit by framework, LiveView and similar offerings work just like a normal server-rendered HTML approach, except that they send dynamic updates to the client without reloading the page when the application state changes. How Do Interactive Server-Rendered Webapps Work? In this post, we'll look at the interactive server-rendered approach, why it's so powerful, and some of the frameworks that offer this functionality in a number of languages. The point here is not that you should never use JavaScript to build a webapp, just that most webapps do not need the server + client-side app approach. Lest I come off as a JavaScript hater, I’ll note that I use JavaScript almost every day on projects where it's the right tool, especially those that rely heavily on browser APIs. The approach was pioneered by LiveView for the Phoenix framework in Elixir, but is now implemented for a variety of other languages and frameworks as well. A new generation of frameworks lets you build webapps that look and feel like single page apps (SPAs), but are driven completely by the server–with no JavaScript. I’m going to let you in on a little secret: you don’t need to write JavaScript to build rich, interactive webapps. Building a modern JavaScript frontend often involves layers and layers of tooling, increasingly opaque frameworks, and all sorts of configuration and compatibility struggles. The ecosystem moves at break-neck speed, sometimes breaking necks along the way. If you’re a frontend developer who likes to keep up to date with the latest in the JavaScript ecosystem, you’re always in for a wild ride. 7 min read No JS - you can build interactive web apps without a line of JavaScript.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |