-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Hi! My team is using a Channel module paradigm that lends itself nicely to ChannelHandler's capabilities, so I was excited to come across this project. In addition to dispatching handle_eventss, we also dispatch joins and handle_infos, which ends up looking something like this:
def join("lobby" = topic, payload, socket) do
Lobby.join(topic, payload, socket)
end
def join("room:" <> _id = topic, payload, socket) do
Dashboard.join(topic, payload, socket)
end
def handle_info({:joined, _user} = msg, socket), do: Notifications.handle_info(msg, socket)
def handle_info({:left, _user} = msg, socket), do: Notifications.handle_info(msg, socket)What do y'all think about adding macros to ChannelHandler for join and handle_info such that something like the following would be possible?
join "lobby", Lobby
join "room:" <> _id, Room
info {:joined, _user}, Notifications
info {:joined, _user}, NotificationsThis would really help us streamline our Channel modules into pure "routers" and I imagine could be useful for other ChannelHandler users. I'm happy to do the work on this feature but would like to gauge the likelihood of something like it getting merged.
While evaluating our options, I prototyped a simple set of macros that do what we need and may be of further use in demonstrating the use case: Dispatcher. Check LobbyChannel and RoomChannel for example usage.
My implementation doesn't include things like scopes and plugs, which I think are awesome features. Furthermore, I'd rather contribute to an existing community effort than create another library.
Happy to chat more, and looking forward to hearing your thoughts.