Managing State Across LiveViews in Elixir Application

145
clicks
Managing State Across LiveViews in Elixir Application
NerdyByDesign, who is relatively new to programming and Elixir, is building an application with numerous tables requiring CRUD operations and seeks to manage state across LiveViews efficiently. They've utilized session storage for tab-specific user choices and are contemplating options like parent-child relationships and PubSub for communication between LiveViews. The desire is to minimize repetitive code and manage state in a tab-specific manner without relying heavily on the browser. Community members suggest utilizing Elixir's OTP and GenServers architecture for communication, emphasizing the flexibility of PubSub beyond Phoenix's implementation, and considering handle_info callbacks for passing messages between LiveViews. However, they discuss the challenge of storing state in a manner that remains reactive and can handle full page refreshes, with suggestions favoring backend over local storage to avoid splitting the source of truth and to ensure consistency.

© HashMerge 2024