Benefits of Phoenix LiveView for IoT
IoT ecosystems contain a lot of data. This includes sensor data from the devices themselves, user data coming from the front-end, and back-end data that lives in the cloud. So, for example, a smart thermometer will take readings and publish the data to an MQTT broker like AWS IoT Core over a topic such as smart_fishtank1/temp.
Now let’s say you own that aquarium, and you open the mobile app to check the water temperature. With LiveView, we can tell that app to subscribe to that same smart_fishtank1/temp topic, so whenever the broker receives a message from the device, it will automatically forward it along to the front-end. This provides a smooth user experience that requires minimal effort.
The benefits of LiveView come into even clearer focus when we start to consider constrained networks like LTE. If bandwidth is a concern, LiveView is an optimal solution because it makes our data transfers as small as possible. A prime example is agriculture IoT. Our devices can collect data about growing conditions that can inform smarter decision-making.
However, for farmers to be able to use these insights, they need to be able to access that data while they’re out in the field—and we certainly can’t expect a high throughput network. Even if the network connection occasionally drops, it’s no big deal; Phoenix LiveView will automatically reconnect when the network connection is reestablished.
Instead of wasting bandwidth on rendering the same page over and over again, LiveView keeps all the static elements in place and just sends the changes: the data itself. What would take KBs to transfer with traditional methods will now only take a few bytes.
The Cons of Phoenix LiveView
Every superhero has their kryptonite, and LiveView is no exception. In fact, the main downside is actually tied to LiveView’s greatest strength; because the server is responsible for rendering everything, the client needs to maintain an active internet connection. LiveView has mechanisms in place to seamlessly restore the connection if it goes out, but a poor cellular signal or a weak internet connection can lead to a lackluster user experience.
Another drawback is that LiveView requires a different mindset for a developer to work effectively in its paradigm. LiveView takes a functional programming approach to front-end development, and this forces the developer to think about the way they build front-ends at a foundational level. Everything has to be done entirely within the server’s rendering system.
Phoenix LiveView: A Powerful Paradigm
Especially for IoT products that already use Elixir for tools like Nerves and NervesHub, LiveView is an even more attractive option because we can leverage talent and streamline integration. That’s exactly what we do at Very.
Are you an Elixir developer? Does creative problem solving with cutting-edge technologies get you as excited as it does us? Well, we have good news for you. We're hiring.