You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm looking into updating my client lib to the new version, where the ChannelProvider context was introduced.
I used to use multiple channels in my components and I wonder if I should wrap my component with multiple ChannelProviders, one for each channel, or if there is a way to have 1 channel provider with multiple channel names.
There is no way to provide a list of channel names for a ChannelProvider. Each ChannelProvider corresponds to a single channel name with its options.
If in your use case you intend to use different channel names inside one component, then you would need to wrap that component in multiple ChannelProvider like this:
However, there is no strict restriction on where exactly you declare a ChannelProvider, as long as it wraps your component which uses the corresponding channel name. This means that if you use different channel names in different components, you can wrap them individually in a more structured way that would suit your app structure.
So you could have something like this:
// somewhere high in your component hierarchy you declare AblyProvider, usually in your App component<AblyProviderclient={client}><ComponentAWrapper></ComponentAWrapper><ComponentBWrapper></ComponentBWrapper></AblyProvider>functionComponentAWrapper(){return(<ChannelProviderchannelName="your-channel-name"><ComponentA></ComponentA></ChannelProvider>);}functionComponentBWrapper(){return(<ChannelProviderchannelName="your-other-channel-name"><ComponentB></ComponentB></ChannelProvider>);}functionComponentA(){// uses 'your-channel-name' channel// ...}functionComponentB(){// uses 'your-other-channel-name' channel// ...}
VeskeR
added
the
documentation
Improvements or additions to public interface documentation (API reference or readme).
label
Apr 18, 2024
Hi there,
I'm looking into updating my client lib to the new version, where the ChannelProvider context was introduced.
I used to use multiple channels in my components and I wonder if I should wrap my component with multiple ChannelProviders, one for each channel, or if there is a way to have 1 channel provider with multiple channel names.
Would appreciate your support.
Thanks!
┆Issue is synchronized with this Jira Task by Unito
The text was updated successfully, but these errors were encountered: