realtime-js icon indicating copy to clipboard operation
realtime-js copied to clipboard

Improve typings for channel presence state

Open agubler opened this issue 2 years ago • 0 comments

Chore

Describe the chore

A user can pass custom state properties via the presence API and since https://github.com/supabase/realtime-js/pull/224 it is now possible to pass a generic that will adjust the types accordingly.

channel.presenceState<MyPresenceState>();

However it would be useful if we could stamp the presence types on creation of the channel

const channel = client.channel<MyPresenceState>('id', config);

// would enforce track to `MyPresenceState`
channel.track({ ... });

// return presence state as `MyPresenceState`
const presenceState = channel.presenceState();

Additional context

Please let me know if this is more than a chore and needs to be recorded elsewhere.

agubler avatar Mar 29 '23 10:03 agubler