supabase-community / realtime-py

A Python Client for Phoenix Channels
MIT License
118 stars 47 forks source link

Payload option for Channel.join() function #134

Open Maturin opened 1 month ago

Maturin commented 1 month ago

Feature request

Is your feature request related to a problem? Please describe.

For an integration project, I need to specify some additional payload, when joining a channel. Therefore, I'd like to enhance the Channel.join function for being able to pass a payload like this:

# common connection and channel setup

join_payload = { 
    "key1": value1,
    "key2": value2
}

channel.join(payload)

Describe the solution you'd like

The Channel._join function foresees already the usage of some payload:

        join_req = dict(topic=self.topic, event="phx_join",
                        payload={}, ref=None)

Therefore, I would add a payload parameter to the join functions, like this:

    def join(self, payload:dict = {}) -> Channel:
        # ...

    async def _join(self, payload:dict) -> None:
        # ...
        join_req = dict(topic=self.topic, event="phx_join",
                        payload=payload, ref=None)
        # ...

Describe alternatives you've considered

n/a

Additional context

This would also effect my ticket #133.