How to create a process subscribed to a channel topic to watch the handle_diff events?

I also needed to deal with such a use case. For anybody stumbling upon this question, basically one just needs to define a GenServer and start the process under the children list in my_app.ex. chrismccord actually provided a quite detailed code example here: https://stackoverflow.com/questions/33934029/how-to-detect-if-a-user-left-a-phoenix-channel-due-to-a-network-disconnect Just call MyApp.Endpoint.subscribe("some:topic") in that process instead of what the original answer did.

3 Likes