ably-js
ably-js copied to clipboard
Decide on renaming `id` field in react-hooks for `AblyProvider` and channel options
id
can be quite misleading in some cases, for example when used like this:
useChannel(
{
channelName: 'your-derived-channel-name',
id: 'rob',
},
(message) => {
updateDerivedChannelMessages((prev) => [...prev, message]);
}
);
you may think that id
here is an id of this channel or something, but in reality it refers to the id used when setting up your AblyProvider
and ChannelProvider
up in the component tree.
Better alternative would be ablyProviderId
, contextId
.
See next comments from PR: https://github.com/ably/ably-js/pull/1620#discussion_r1497782783, https://github.com/ably/ably-js/pull/1620#discussion_r1502826007 for more info.
Copying Slack conversation here: Owen:
i think ablyProviderId sounds fine, although i would maybe argue that it's used for identifying the wrapped realtime client rather than just the provider so on that basis, maybe just ablyId would suit?
Me:
hmm, I see. also, AblyProvider and ChannelProvider both set something on context, but AblyProvider is responsible for providing realtime client, and ChannelProvider is responsible for providing options for channels. and the "id" you use for those providers should match, thus calling it ablyProviderId might be a bit too specific there is also an option to call it contextId, or ablyContextId
Owen:
i like ablyContextId more than ablyProviderId
ablyId
and ablyContextId
both sound good and should prevent people from thinking that this "id" is related to a channel, instead of provider components. So we decided to go with shorter variant ablyId
.
Done in https://github.com/ably/ably-js/pull/1676