nathanl
Example usage of `Phoenix.Presence.list/2`?
I’m trying to understand how to use Phoenix.Presence.list/2. It shows the arguments as module, topic.
My guess was that module should be the channel module, but when I call Phoenix.Presence.list(MyApp.MyChannel, "my_topic"), I get an ** (EXIT) no process error from GenServer.call.
I’m using Presence in the channel module the way the docs show, and I’m successfully getting presence_state and presence_diff messages in the browser.
My goal is to get a list of connected users for that topic so that I can send each one of them some data customized for their user id.
Am I using Phoenix.Presence.list/2 wrong?
Most Liked
dom
It’s referring to your app’s presence module. Phoenix.Presence.list(MyApp.Presence, "my_topic") should do the trick. But you can also just call MyApp.Presence.list("my_topic"), that function is inserted into your presence module in this macro.
nathanl
Oh! Yes, that works. Thanks! ![]()
I guess that implies that each topic needs a globally unique name, even though they’re handled by different channels. ![]()
OvermindDL1
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









