

ELIXIR LIVEVIEW UPDATE
However, when I have previously implemented language switching for a standard Phoenix application, compared with frontend-only Elm, needing to make a request back to the server to change the application locale means that a bit more time is needed before the update is visible on screen.

The blog post goes through different methods I used to get internationalisation ( i18n) working, but, in my opinion, the options in Elm as of this writing are not quite as nice as Elixir’s gettext- based API. Refresh the page, and you will see that your choice of language is remembered.If you select a different language, the language of the page content and title will change, and the list of selectable languages in the dropdown menu will update.Click the current language again, or anywhere else on the page, and the menu closes.Click on the current language, and the menu opens, showing a list of selectable languages.The page is deployed here, and you can find the code here, but to save a click, the animated GIF above shows all of its use cases:
ELIXIR LIVEVIEW FULL
In a previous blog post, Runtime Language Switching in Elm, I re-created the Tachyons Full Screen Centered Title component documentation page in Elm, and added a language dropdown menu to change the page language.
ELIXIR LIVEVIEW INSTALL
Install the dependency in your mix.exs file:ĭef deps do [ = MyApp.

The following steps are detailed in Phoenix LiveView Readme. Let’s get LiveView up and running to support a feature that pushes out live updates as our server enacts a step-by-step process of creating a GitHub repo. Phoenix LiveView feels like a perfect fit for the 90% of the time that you do want some live updates but don’t actually need the wrecking ball of many modern JS frameworks. If you’ve waded through an overly complex SPA that Reduxes all the things (for example), you’ve felt the maintenance and iteration costs that often accompany all that fancy JavaScript. LiveView powered applications are stateful on the server with bidirectional communication via WebSockets, offering a vastly simplified programming model compared to JavaScript alternatives. Phoenix LiveView is an exciting new library which enables rich, real-time user experiences with server-rendered HTML.

Keep in mind that the library is still a release candidate and as such, is subject to change.Ĭhris McCord said it best in his announcement back in December: Phoenix LiveView is brand brand new so I thought I’d provide a short write-up of a super simple demo I built for anyone looking to get up and running. If you’re sick to death of writing JS (I had a bad day with Redux, don’t ask), then this is the library for you! It’s here! Phoenix LiveView leverages server-rendered HTML and Phoenix’s native WebSocket tooling so you can build fancy real-time features without all that complicated JavaScript.
