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

Not able to count how many listeners are there for a channel #1767

Open
luizoppy opened this issue May 19, 2024 · 1 comment
Open

Not able to count how many listeners are there for a channel #1767

luizoppy opened this issue May 19, 2024 · 1 comment
Labels
enhancement New feature or improved functionality.

Comments

@luizoppy
Copy link

luizoppy commented May 19, 2024

I am relying on the imperative API to subscribe to the channels channel?.subscribe(eventName, ...). I am trying to control the lifecycle of my application so as soon as there are no more subscriptions on a given channel, I want to detach it. The problem is that channel.listeners() when called without the eventName parameter does not return the listeners which are not "any" listeners. This seems counter intuitive. Additionally, knowing how many subscriptions are there for a given channel is very useful to control attaching/detaching of channels.

Are there alternative ways of knowing how many subscriptions are there without having to track all possible events to which users may have subscribed to?

┆Issue is synchronized with this Jira Task by Unito

@ttypic ttypic added the enhancement New feature or improved functionality. label May 21, 2024
@ttypic
Copy link
Collaborator

ttypic commented May 21, 2024

Hey @luizoppy,

Thank you very much for raising this. I agree that the channel.listeners() method contract can be a bit confusing. We don't want to change the implementation right now because it will introduce breaking changes, and other clients may rely on the current implementation. We will think about adding a new method, something like channel.allListeners(), with the behavior you desire. This improvement in our high priority list and we'll keep you posted.

Meanwhile, I can only suggest you add your own listener counter that will be responsible for calculating active listeners for the channel.

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

2 participants