Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

channels.all not exposed in typescript types #1776

Open
bastiankistner opened this issue May 26, 2024 · 2 comments
Open

channels.all not exposed in typescript types #1776

bastiankistner opened this issue May 26, 2024 · 2 comments
Labels
enhancement New feature or improved functionality.

Comments

@bastiankistner
Copy link

bastiankistner commented May 26, 2024

I was just looking for a way to ensure that all channels have been detached and released before I try to re-authorize the client with a different set of capabilities. I found that the actual instance of my realtime client provides a .all property on the channels object. But it's not exposed through the typescript definitions.

Is this intended behaviour or do I need to use a different way to instantiate my client?

Here is the particular code I'm talking about:

all: Record<string, RealtimeChannel>;

and I instantiate the client as mentioned in the docs:

import * as Ably from 'ably';

let options: Ably.ClientOptions = { key: 'foo' };
let client = new Ably.Realtime(options); /* inferred type Ably.Realtime */
let channel = client.channels.get('feed'); /* inferred type Ably.RealtimeChannel */

┆Issue is synchronized with this Jira Task by Unito

@lawrence-forooghian
Copy link
Collaborator

Hi @bastiankistner, channels.all is not part of the public API of the library. If you wish to perform an operation on all channels, I'd suggest that you keep your own list of the channels that you've instantiated (i.e. you should add to this list each time you call channels.get()).

As far as I know, this is not a feature that is frequently requested, so I’d like to understand your use case a bit better. What's your motivation for needing to "ensure that all channels have been detached and released before (you) try to re-authorize the client with a different set of capabilities"?

@bastiankistner
Copy link
Author

Hello @lawrence-forooghian !

I'm building a collaborative realtime multichannel ecommerce fulfillment application that is supposed to handle market orders in batches and allows for multi-tenancy. The latter is the reason why I need to switch capabilities and re-authorize.

I'm using ably's realtime communication for the following aspects:

  • to ensure that only a single client for a single user can ever use the system at the same time to keep the amount of sent messages as low as possible (lead management)
  • sending printjobs from the web browser to a rust based cross platform print client that acts as a cloud print server
  • synchronize locking of orders to avoid conflicts
  • synchronize the order status across clients and instruct them to refresh their data from the cloud database

Since a user can be part of multiple organizations, each with a different set of marketplaces and potential connected print clients, I have to tear down all channels when the user switches the organization and re-establish a newly authorized connection with the corresponding channels.

It took me a while to properly integrate ably into my system and I realized that I need more control over what's happening, which is why I turned from the react sdk to the plain js sdk. And to further increase transparency I was looking for ways that the sdk offers that could be of value. Then I stumbled upon the channels.all property and was wondering why ably doesn't publicly expose it as it would already provide a great tool to track channel usage.

@VeskeR VeskeR added the enhancement New feature or improved functionality. label Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improved functionality.
Development

No branches or pull requests

3 participants