Creating a Distributed Timer Using Phoenix LiveView

88
clicks
Creating a Distributed Timer Using Phoenix LiveView

Source: chrisodonnell.dev

Type: Post

This article explains the implementation of a distributed timer in a Phoenix LiveView app, where one user can start a timer visible to others in their group. The timer features functionalities such as pausing, restarting, and stopping. It emphasizes state management and communication strategies using client-side hooks, server events, and Phoenix Pubsub to ensure all users see a consistent timer state. The database retains timer states, accommodating scenarios where users might disconnect. Moreover, client-side logic ensures a smooth user experience without depending on the accuracy of users' clocks. The article also highlights testing strategies for the timer functionality to confirm communication and updates work correctly among users.

© HashMerge 2025