Allow Phoenix.Presence to specify the message dispatcher

Phoenix.Presence sends “presence_diff” events using

Phoenix.Channel.Server.local_broadcast/4

If someone is using a non-standard metadata when subscribing to the topic it’s not possible to specify a custom dispatcher module. It will always use the Phoenix.Channel.Server.dispatch/3 function.

Would it make sense to allow a :dispatcher option and use instead:

 broadcast = %Broadcast{
      topic: topic,
      event: "presence_diff",
      payload: presence_diff
    }
Phoenix.PubSub.local_broadcast(state.pubsub_server, topic, broadcast, dispatcher) 

where dispatcher defaults to Phoenix.Channel.Server

Thoughts?

1 Like