Wrapping Up

Let's highlight the main contents of this chapter.

Putting this all together

LiveView

LiveView allows us to write real-time interfaces with little to no JavaScript. LiveView builds on the power of Elixir, Phoenix Channels, and Phoenix PubSub to provide a stable and efficient base. With LiveView, we express our user interface and behavior in a declarative format. This would normally be difficult for real-time interactive applications that span multiple languages, but LiveView makes it feel intuitive. LiveView’s unidirectional data flow, combined with its declarative model, makes our applications clearer to read, extend, and maintain.

Applications using LiveView

We rewrote the real-time product page from earlier chapters using LiveView. Amazingly, we didn’t change our application’s business logic at all. We wrote a LiveView that renders the same template as our controller did previously and handles the same messages that we were already emitting in our application.

Tests with LiveView

Our existing automated acceptance tests worked out-of-the-box with LiveView. We only had to point them at the new interface instead of the old one. We wrote new tests for our LiveView using the provided test helpers. These tests were a breeze to write and read, due to the simplicity of the LiveViewTest helpers.

In the near future

As of the time of writing this course, LiveView is still rapidly evolving and becoming more polished. Features may be slightly different than what is presented in this course, but the essence is the same. There will be even more features and optimizations available in the future. Also, as Phoenix Channels and Elixir evolve, so will LiveView. Its strong technical foundations in these existing technologies provide a feedback loop where improvements in one can potentially provide improvements to the others.

We’re going to look at a completely different way of writing application front-ends next. We’ll see how Phoenix Channels can easily be integrated into React single-page apps, or even React Native mobile apps.

Get hands-on with 1200+ tech skills courses.