In a project I’m working on, I have a menu in my app layout that displays a number of unread messages. Because this is in the app layout, it does not belong to any one LiveView instance, but to all of them. When a new message comes in, or a message is marked as read, there is a broadcast on a PubSub channel that communicates the unread change. While you can subscribe to a channel within a LiveView, you can’t subscribe to a channel across all LiveViews in order to update what is essentially global state.

continue reading on andrewtimberlake.com

⚠️ This post links to an external website. ⚠️